Working with Form Arrays in ColdFusion?(在 ColdFusion 中使用表单数组?)
问题描述
我不知道如何在 ColdFusion 9 中处理这个问题,我提交了一个带有元素复选框的表单 (POST),称为 items[].
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?想法?我有点难过,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/开发中/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 不是最简单的语言查找示例/参考净;)
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/
这篇关于在 ColdFusion 中使用表单数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 ColdFusion 中使用表单数组?
基础教程推荐
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 直接将值设置为滑块 2022-01-01