I'm using MX7 and need to build up a variable number of fields in a form.
Creating the variable list of fields to match number of items in list creates
no problem -
<cfloop index = "yy" from = "1" to = #List_No#>
<cfinput type="text" name="DOB" id="DOB"/><br />
</cfloop>
That's fine. The problem is changing the name or ID of the field from DOB1 to
DOB2 etc, and how does the the next page detect #Form.DOB1# and #Form.DOB2# etc.
Thanks
cf_dev2 - 28 Jun 2007 18:31 GMT
Put the index after each field name
<cfinput type="text" name="DOB#yy#" id="DOB"/>
Store the #List_No# in a hidden field
<input type="hidden" name="List_No" value="#List_No#">
On the next page use the same kind of loop to grab the field names
<cfloop index = "yy" from = "1" to = #form.List_No#>
<cfoutput>
form.DOB#yy# = form["DOB#yy#"]>
</cfoutput>
</cfloop>
Obviously use cfoutput where needed.