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
the problem was something else...i have 6 different arrays of input tags...and all arrays have 3 values i.e<br><br><input type=text name=rec1 value=(some value)><br><input type=text name=rec1 value=(some value)><br><input type=text name=rec1 value=(some value)><br><br><input type=text name=rec2 value=(some value)><br><input type=text name=rec2 value=(some value)><br><input type=text name=rec2 value=(some value)><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><cfset rec1=arraynew()><br><cfset rec2=arraynew()><br><br><cfset rec1[1]=rec11><br><cfset rec1[2]=rec12><br><cfset rec1[3]=rec13><br><br><cfset rec2[1]=rec21><br><cfset rec2[2]=rec22><br><cfset rec2[3]=rec23><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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.