I’ve been playing around with the code offered here:
[URL=”http://javascript.internet.com/forms/adding-html-controls.html?start_comment=10″]http://javascript.internet.com/forms/adding-html-controls.html?start_comment=10
Right now I have 10 rows that are static, and each row has an “add/delete” button to add more text fields WITHIN the row.
The problem is this:
[LIST][*]
Row 1: Add text field
Row 2: Add text field (it now adds TWO text fields)
Row 3: Add text field (it adds THREE)
Delete functions in a similar manner
Online sample here: [URL=”http://music.manentia.com/”]test
So, it’s putting the extra text fields where I want them, but I can’t separate out each row and have the code treat them separately.
Here’s the JS code. Of course, thank you to anyone that can help!
[CODE]// JScript File
var arrInput = new Array(0);
var arrInputValue = new Array(0);
var number; //ADDED, this is passed from the add/delete function to specify rows
function addInput(i) {
number = i
arrInput.push(arrInput.length);
arrInputValue.push(“”);
display();
}
function deleteInput(i) {
number = i
if (arrInput.length > 0) {
arrInput.pop();
arrInputValue.pop();
}
display();
}
function display() {
document.getElementById(‘parah’+number).innerHTML=””;
for (intI=0;intI<arrInput.length;intI++) {
document.getElementById(‘parah’+number).innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
}
}
function saveValue(intId,strValue) {
arrInputValue[intId]=strValue;
}
function createInput(id,value) {
return id+2 + “. <input type=’text’ id=’name” + number + “-“+ id +”‘ onChange=’javascript:saveValue(“+ id +”,this.value)’ value='”+ value +”‘ size=’40’><br>”;
}