I have a form that contains a <cfoutput> which lists several records. I want to
pass the value of the form field to my action page.
In the form the "name" of the form field is set as follows:
name="guests#RecordCounter#" where RecordCounter is the index number.
In my action form I have the follow statement which doesn't work: <cfset
guests = evaluate(form.guests#i#)> where i is the counter. How do I extract the
value from this form field.
Any help would be greatly appreciated.
Grizzly9279 - 31 Aug 2007 02:21 GMT
Try a <cfdump var="#form#"> to see what's getting posted...
cf_dev2 - 31 Aug 2007 02:35 GMT
Use array notation
<cfset guests = form["guests#i#"] >
Grizzly9279 - 31 Aug 2007 05:31 GMT
Ah yes. cf_dev2's comment sort of highlighted for me what was wrong with your
code. You missed the quotes from your evaluate() statement. And as cf_dev2
pointed out, it's actually preferrable to use a direct structure/key reference,
instead of evaluate. Nevertheless, you could do this in one of 4 ways as I see
it:
<cfset guests = evaluate( "form.guests#i#" )>
<cfset guests = evaluate( "form.guests"&i )>
<cfset guests = form["guests#i#"] >
<cfset guests = form["guests"&i] >
I personally prefer the last one.
drmaves - 02 Sep 2007 17:47 GMT
Thanks cf_dev2 and Grizzly9279 for your help - your solutions worked great!