Spot on answer. The loop where you set fromZone, toZone etc solved it.
Thanks!
Main Topics
Browse All TopicsI've got a form for editing price lists that are tied to X zones. The zone count can increase and decrease.
Drop down menu = from zone
The form loops through all available zones (which can increase/decrease if a zone is added/removed - hence the need for dynamics), and creates input boxes for each zone.
Zone ID1/Name - price
Zone ID2/Name - price
Zone ID3/Name - price
etc.
At submit, I need to loop through the form and populate the SQL database, which contains fromZone, toZone, price.
Problem is the loop - I've got no idea how to make it work. Any ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: _agx_Posted on 2009-10-07 at 18:59:32ID: 25521912
Just name each set of form fields sequentially. I know your form is dynamic, but this concept is best demonstrated with a hard coded loop. The code below creates multiple sets of the fields: fromZone, toZone and price. Each set has the same suffix to group the fields together.
elect> ect>
#">
nes" default="0"> es#" index="row">
<cfoutput>
<cfloop from="1" to="#totalNumberOfZones#" index="row">
<select name="fromZone#row#">....</s
<select name="toZone#row#">....</sel
<input name="price#row#" type="text">
...
</cfloop>
</cfoutput>
Somewhere outside the loop, store the total number of fields generated:
<!--- store the total number of fields --->
<cfoutput>
<input type="hidden" name="totalNumberOfZones" value="#totalNumberOfZones
</cfoutput>
On your action page, just loop from 1 to #totalNumberOfZones# to extract the values. Then insert the values into your database as usual.
<cfparam name="form.totalNumberOfZo
<cfloop from="1" to="#form.totalNumberOfZon
<!--- extract the values --->
<cfset fromZone = FORM["fromZone"& row]>
<cfset toZone = FORM["toZone "& row]>
<cfset price= FORM["price"& row]>
<!--- validate and INSERT as usual --->
<cfquery ...>
INSERT INTO SomeTable ....
</cfquery>
</cfloop>