在ColdFusion中使用表单数组? [英] Working with Form Arrays in ColdFusion?
问题描述
我不知道如何处理这个在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 =#form#/>
获得所有显示具有正确名称的项目,例如 items []
,例如:
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[]
但是执行< cfdump var =#form.items []#/>
会导致错误。如何访问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的出来?想法?我有点郁ped,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.
谢谢! >
Thanks!
推荐答案
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
Dot notation doesn't work 'cause of the '[]'
. See: 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 list =:
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.
想法,我有点累了,
coldfusion不是最简单的语言
在$上找到例子/引用b $ b net;)
Thoughts, I'm kindof stumped and coldfusion isn't the easiest language to find examples / references on the net ;)
- 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/
- 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中使用表单数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!