I have an indefinite number of textfields created on my page. I need to loop through each one and retrieve the data that was input by the user and stor them so that i can load them into the database. The textfields are created in a loop that are named incrementally, description textfield and a part no textfield, as such: desTextfield1 pnoTextfield1 desTextfield2 pnoTextfield2 desTextfield3 pnoTextfield3 desTextfield4 pnoTextfield4 desTextfield5 pnoTextfield5 desTextfield6 pnoTextfield6 . . . desTextfieldn pnoTextfieldn Is this code correct...in that the textfields name is referred to as textfield1, textfield2, etc..? document.getElementById("textfields").innerHTML += 'Item '+numItems+' Description<INPUT TYPE="text" NAME="idescription '+numItems+'" > Part Number <INPUT TYPE="text" NAME="ipartno '+numItems+'" VALUE="" ONKEYDOWN="if (event.keyCode==9) { addNewItem(); }">'; Code (markup): If so, how do i go about looping through those textfields? I was thinking that maybe i will be needing a 2 dimensional array...that way each element of the array will hold a description field and a part no field. Then when i need to load into the database i could loop through each array element and populate the database. Please let me know if this would work correctly and how i would go about it. Thanks in advance.
You want to name the text fields as an array: text_field[] Then you can loop through them in your processing code. I hope this helps, Bob
Description<INPUT TYPE="text" NAME="idescription[]" > Part Number <INPUT TYPE="text" NAME="ipartno[]" VALUE="" ONKEYDOWN="if (event.keyCode==9) { addNewItem(); }">';