paldie
asked on
Looping Through Dynamic Form Fields
I am working on a form that initially has some fields, but the user can also add more dynamically.
All fields follow the name var#index# and price#index# where #index# is the number of lines in the form so far. Also form fields are always 1 var field and 1 price field. The extra fields are added via a jQuery function.
So now I need to process the form once submitted. Is there a way I could loop over the fields to get the values?
Let me know if you need any code.
PS there is also one other field in the form called title.
PPS the form is in an application driven by the FW/1 framework so I don't have the form scope. Instead I have the Request Context (RC scope) which essentially contains the request scope.
All fields follow the name var#index# and price#index# where #index# is the number of lines in the form so far. Also form fields are always 1 var field and 1 price field. The extra fields are added via a jQuery function.
So now I need to process the form once submitted. Is there a way I could loop over the fields to get the values?
Let me know if you need any code.
PS there is also one other field in the form called title.
PPS the form is in an application driven by the FW/1 framework so I don't have the form scope. Instead I have the Request Context (RC scope) which essentially contains the request scope.
ASKER
That is exactly what I need to do. I am not sure what you are doing on that cfset, but the first part I get and then I know exactly how to process it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help. That was exactly what I was looking for.
Also for performance do not recommend using evaluate
Use this notation
<cfset var=form["var#i#"]>
Use this notation
<cfset var=form["var#i#"]>
thank you
ASKER
Because the processing this withing FW/1 and everything is thrown into the RC struct would it be possible to call rc['var#i#']? RC holds the form structure.
sure. Are you using a coldbox?
ASKER
No it is FW/1 (and Transfer ORM). It is Sean Corfield's framework, which is a great introduction into Frameworks. It doesn't use any XML files for configuration, instead it builds views, layouts, controllers, and services by directory structure. Have a full E-Commerce application built on it using 4 different sub-systems (mini applications).
http://github.com/seancorfield/fw1/
http://github.com/seancorfield/fw1/
ANd do
<cfset t = form["name" & ID]>