Domanda

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!

È stato utile?

Soluzione

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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top