问题描述
我不知道如何在ColdFusion的9处理这个问题,我已经提交的表单(POST)以元素复选框,称为项目[]。
I have no idea how to handle this in ColdFusion 9, I have a form being submitted (POST) with element checkboxes, called items[].
当我做了< cfdump VAR =#形式#/>
没有问题,我得到适当的名称所示的所有物品如项目[]
例如:
When I do a <cfdump var="#form#" />
no-problem, I get all the items shown with the proper names like items[]
eg:
struct
ITEMS[] 13,14
FIELDNAMES ITEMS[]
但做一个&LT; cfdump VAR =#form.items []#/&GT;
导致错误。我如何访问CF9字段值?通过它不知怎么循环?
however doing a <cfdump var="#form.items[]#" />
results in an error. How do I access the CF9 field values? Somehow loop through it?
我似乎无法与阵列,以获得ID的出它做什么?思考?我有点难倒和ColdFusion是不是在网络上找到的例子/引用最简单的语言。 ;)
I cannot seem to do anything with the array to get the id's out of it? Thoughts? I'm kind of stumped and ColdFusion isn't the easiest language to find examples / references on the net. ;)
有没有处理这个正确的方式?我需要得到的ID的离开那里,所以我可以参考什么行的形式进行了检查,这样我就可以有动作跟进。
Is there a correct way to deal with this? I need to get the ID's out of there so I can reference what lines were checked in the form, so I can follow up with an action.
谢谢!
推荐答案
有没有数组形式,在ColdFusion的。有[]
结尾并不能使一个数组。您可以从表范围的复选框值是这样的:
There's no Form Array’s in ColdFusion. Having '[]'
at the end doesn't make it an array. You can access the checkbox values from form scope like this:
FORM["ITEMS[]"]
点符号不工作的原因[]
。参见:http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7fb2.html
从复选框值只是逗号分隔值,这是一个ColdFusion的列表
Values from checkboxes are just comma separated values, which is a List in ColdFusion
要通过它循环,使用CFLOOP列表=
To loop through it, use cfloop list=:
<cfoutput>
<cfloop index="i" list="#FORM['ITEMS[]']#">
#i#
</cfloop>
</cfoutput>
要一个列表转换为数组,使用ListToArray().有列表的功能,如 listGetAt()
,但如果你正在做大量的随机访问,这将会是更聪明到列表中第一个转换为数组。
To convert a list to array, use ListToArray(). There are list functions like listGetAt()
, but if you're doing lots of random access, it'd be smarter to convert the list into an array first.
思考,我kindof住了,
ColdFusion不不是最简单的语言
找到这些示例/引用
网;)
- http://help.adobe.com/en_US/ColdFusion/9.0/Developing/index.html
- http://learncf.com/tutorials
- http://www.easycfm.com/
- http://www.carehart.org/ugtv/
这篇关于在ColdFusion表单数组工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!