Hello, I have been looking all over for some help on this mater..
Item: (input field) Price: (input field)
the javascript is working great and it adds the two fields every time i click add more.
now the problem,
If i add one line of “item, and Price” then enter values in to the fields, then click on the link to add more fields it will take the “price” value and put it in the “item” field. So now it will have the value i put in the “price” in both field “item, and Price”.
How can i stop this and have the fields keep there values as i add more inputs?
var arrInput = new Array(1);
var arrInputValue = new Array(1);
function addInput() {
arrInput.push(arrInput.length);
arrInputValue.push(“”);
display();
}
function display() {
document.getElementById(‘parah’).innerHTML=””;
for (intI=1;intI<arrInput.length;intI++) {
document.getElementById(‘parah’).innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
}
}
function saveValue(intId,strValue) {
arrInputValue[intId]=strValue;
}
function createInput(id,value) {
return “Item: <input type=’text’ name=’item[“+ id +”]’ id=’item”+ id +”‘ onChange=’javascript:saveValue(“+ id +”,this.value)’ value='”+ value +”‘> Price: <input type=’text’ name=’price[“+ id +”]’ id=’price”+ id +”‘ onChange=’javascript:saveValue(“+ id +”,this.value)’ value='”+ value +”‘><br>”;
}
function deleteInput() {
if (arrInput.length > 0) {
arrInput.pop();
arrInputValue.pop();
}
display();
Thank you very much!