I am trying to insert some records based on a submitted form. The form page will submit multiple records to an action page. The action page will then do a loop for each record submitted, and insert some info into the DB. My problem is that one of the fields on the form has a dynamic name.
I'm not sure how to loop through the results and get the appropriate form field name for each record.
The field in question on the form is the one with name="#contact_id#". On the action page, the values from that field should be inserted as the 'sent_code' value.
Anyone know how to do this? Thanks in advance.
Form page code:
<cfif ...>
<input type="hidden" name="#contact_id#" value="1">
<cfelseif ...>
<input type="hidden" name="#contact_id#" value="2">
<cfelseif ...>
<input type="hidden" name="#contact_id#" value="3">
<cfelseif ...>
<input type="hidden" name="#contact_id#" value="4">
</cfif>
<input type="hidden" name="contact_id" value="#contact_id#">
<input type="submit" value=" Submit " name="submit_form">
Action page code:
<cfset contact_list = form.contact_id>
<cfloop list="#contact_list#" index="id">
<cfquery name="insert_it" datasource="#ds#">
INSERT INTO sri_contact.dbo.contact_cob_sent_tracker(contact_id, sent_code, date_sent)
VALUES(#id#, #sent_code#, #DateFormat((Now()), "mm/dd/yyyy"#)
</cfquery>
</cfloop>
I'm not sure how to loop through the results and get the appropriate form field name for each record.
The field in question on the form is the one with name="#contact_id#". On the action page, the values from that field should be inserted as the 'sent_code' value.
Anyone know how to do this? Thanks in advance.
Form page code:
<cfif ...>
<input type="hidden" name="#contact_id#" value="1">
<cfelseif ...>
<input type="hidden" name="#contact_id#" value="2">
<cfelseif ...>
<input type="hidden" name="#contact_id#" value="3">
<cfelseif ...>
<input type="hidden" name="#contact_id#" value="4">
</cfif>
<input type="hidden" name="contact_id" value="#contact_id#">
<input type="submit" value=" Submit " name="submit_form">
Action page code:
<cfset contact_list = form.contact_id>
<cfloop list="#contact_list#" index="id">
<cfquery name="insert_it" datasource="#ds#">
INSERT INTO sri_contact.dbo.contact_cob_sent_tracker(contact_id, sent_code, date_sent)
VALUES(#id#, #sent_code#, #DateFormat((Now()), "mm/dd/yyyy"#)
</cfquery>
</cfloop>