Hi, guys.
I’m trying to add a row of fields like the following when I press a button.
name[] height[] age[]
name[] height[] age[]
name[] height[] age[]
I need that [] bracket to process the values in an array for PHP later.
So, obviously I could createElement for each one and append them, but I wanted to use a loop for efficiency and for later expendability. But for some reason, nothing happens when I press the button. Is there something that I’m missing?
[CODE] function addform() {
var defaultName = new array(“name”, “height”, “age”);
var formName = new array(“nameForm”, “heightForm”, “ageForm”);
var count=defaultName.length
var i=0
for (i=0; i<=count; i++) {
formName[i] = document.createElement(“input”);
formName[i].type = “text”;
formName[i].name = defaultName[i] + “[]”;
inHere = document.getElementById(“inhere”);
inHere.appendChild(formName[i]);
}
}