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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate <input name> during loop?

Status
Not open for further replies.

jad73

Programmer
Apr 26, 2001
33
US
I have a form which ask the user the quantity of equipment that needs to be scanned. A loop begins and creates input boxes to the exact number the user enters. Is there a way to name the boxes as they are being created during the loop so that i can in turn upload the information to my database?
 
you can use the counter in the loop to name them.
example in the loop for text names of txt and increment them by 1 each loop
name='txt'+ i ---------------------------------------
{ str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee");alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
Like this:

for(var i=0;i<50;i++){
document.write(&quot;<option name='name_&quot;+i+&quot;'>&quot;);
}

Rick -----------------------------------------------------------
 
If you're using createElement, then make sure you assign it to a variable first, then use
variableName.name = &quot;box&quot; + yourCounterVar;

where yourCounterVar is your loop counter variable.

Make sense? If not, show us your code and we should be able to amend it.
Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) &&(((parseIntx.toString()+y.toString())-x-y)%9)!=0)){alert(&quot;I'm a monkey's uncle&quot;);}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top