如何处理任意数量的表单字段

发布于 2024-12-23 18:39:02 字数 201 浏览 6 评论 0原文

我正在使用 ColdFusion (Railo 3.3),并且我有几个使用 jQuery 的表单,可以动态添加一组表单字段(例如,用户可以勾选一个框来添加另一个公司所有者,该框会显示附加的所有相关字段)所有者)。所有信息都需要插入数据库,但我不知道在任何给定时间将提交多少字段。

如何使用 ColdFusion 处理任意数量的字段以插入到数据库中?

谢谢!

I am using ColdFusion (Railo 3.3), and I have several forms using jQuery that can dynamically add a set of form fields (for instance, the user can tick a box to add another company owner that brings up all the relevant fields for the additional owner). All the information needs to be inserted into a database, but I don't know exactly how many fields will be submitted at any given time.

How do I process this arbitrary number of fields to insert into a DB with ColdFusion?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗笺 2024-12-30 18:39:02

表单是一种结构,也称为集合。

您可以循环整个表单结构并插入所有字段,您可能需要排除一些字段,例如提交按钮等,但您应该知道其名称。

<cfloop collection=#form# item="field"> 
    <cfif field neq 'submit'>
        .... insert into DB #form[field]#
    </cfif>
</cfloop>

Form is a structure aka Collection.

You can just loop over the entire form structure and insert all the fields, you will probably need to exclude some like the submit button etc, but you should know the name of this.

<cfloop collection=#form# item="field"> 
    <cfif field neq 'submit'>
        .... insert into DB #form[field]#
    </cfif>
</cfloop>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文