• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating Form Fields Based on Arrays

Guest
Jun 28, 2007 Jun 28, 2007

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

239

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 28, 2007 Jun 28, 2007

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation