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 / September 2007



Tip: Looking for answers? Try searching our database.

Extracting a value from indexed form field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
drmaves - 31 Aug 2007 02:01 GMT
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!
 
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.