|
[x]
Posted via EE Mobile
|
|
| Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
|
|
|
|
Asked by mindboom in JavaScript
I've been playing around with the code offered here:
http://javascript.internet.com/forms/adding-html-controls.html?start_comment=10Right 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:
* 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
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!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
|
// JScript File
var arrInput = new Array(0);
var arrInputValue = new Array(0);
var number;
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='30'><br>";
}
|
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625