Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FORM Collection

Status
Not open for further replies.

saurabh

Programmer
Jul 10, 2000
27
IN
How do i traverse the FORM collection. I have 5 input tags of same name in the form, whose name is rec1...how do i access rec1(0)...individual values of the array through CFML.<br><br>- Saurabh
 
cfloop over the formfields !!! (btw it's in the doc !!)
 
the problem was something else...i have 6 different arrays of input tags...and all arrays have 3 values i.e<br><br>&lt;input type=text name=rec1 value=(some value)&gt;<br>&lt;input type=text name=rec1 value=(some value)&gt;<br>&lt;input type=text name=rec1 value=(some value)&gt;<br><br>&lt;input type=text name=rec2 value=(some value)&gt;<br>&lt;input type=text name=rec2 value=(some value)&gt;<br>&lt;input type=text name=rec2 value=(some value)&gt;<br><br>..and so on<br><br>now these input tags are generated dynamically based on some condition, so names have also been generated dynamically.....<br><br>now the problem is that first array (first 3 input tag values) have to update 1 record in sql database....second array will update 2nd record...and so on.<br><br>now want to travese this loop....<br><br>suggest something....<br>
 
if i understand it ... you want the retrieve 3 DIFFFERENT values for rec1.value, right ???!!!!!!!!!!!!!!!<br>i think it's a jscript roblem : you just can't recall rec1.value and suppose the system knows which one of the 3 you want !!!!!<br>the only solution i see is the one i already told you : cfloop over the formfields !!!!!!!!! this way the system doesn't care for the name of the field ...<br>just : <br>* get the form.fieldnames<br>* transform it as an array<br>* cfloop over the array<br>* evaluate(the_array[counter]) is the value of the counter-th field in the form and the_array[counter] is the NAME of the field<br>right ???<br><br><br><br><br>
 
Hallo Saurabh<br>If you have the same name for an input you can only get the value of the first one declared. They have to have unique names else it is imposible.<br>Coldfusion can't think by itself, you have to tell the server what to do.<br>A solution could be that you cal the input boxex the names:<br>rec11<br>rec12<br>rec13<br><br>rec21<br>rec22<br>rec23 and so on<br><br>Doek1
 
doek1 : i'm quite sure it can work in cf as i said above, coz it does'nt care for the name only for the position in the array (or list it depends)<br>i've already made it work ;]]
 
I think the easiest way to make this work would be to do as Doek1 says, then on the action page, do something like:<br><FONT FACE=monospace><b><br>&lt;cfset rec1=arraynew()&gt;<br>&lt;cfset rec2=arraynew()&gt;<br><br>&lt;cfset rec1[1]=rec11&gt;<br>&lt;cfset rec1[2]=rec12&gt;<br>&lt;cfset rec1[3]=rec13&gt;<br><br>&lt;cfset rec2[1]=rec21&gt;<br>&lt;cfset rec2[2]=rec22&gt;<br>&lt;cfset rec2[3]=rec23&gt;<br>.....<br></b></font><br>Once you've done that, you can do whatever array type processing you need... (you could also put this in a loop if there's a lot of fields to deal with...)<br><br>Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top