Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / June 2007



Tip: Looking for answers? Try searching our database.

Creating Form Fields Based on Arrays

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FreddyBlogs - 28 Jun 2007 17:46 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.