J
joltman
OK, this is kind of hard to explain, so I'll do my best:
I have a form where I have a row where there could be multiple entries,
so I have a link where it will dynamically add another row like it, and
this can happen as many times as you click on the link. This row
consists of 2 drop-down boxes. Depending on the selection of the first
drop-down box, the second drop-down box is either disabled or enabled.
The problem is on these dynamically created rows. Here is the code for
the dynamically created first drop-down:
var cell = row.insertCell(0);
var elSelect = document.createElement('select');
elSelect.setAttribute('name','country[' + regionNumber + ']');
elSelect.setAttribute('id','country[' + regionNumber + ']');
elSelect.setAttribute('onchange','changeCountry(regionNumber)');
regionNumber is a variable that gets 1 added to it every time this
function runs.
As you can see, there is an onchange event handler. The problem is if I
make the onchange occur, it uses the current value of regionNumber, but
I want it to use the value that regionNumber was when that setAttribute
code ran.
Can anyone help me? If I need to further explain, please tell me so.
I have a form where I have a row where there could be multiple entries,
so I have a link where it will dynamically add another row like it, and
this can happen as many times as you click on the link. This row
consists of 2 drop-down boxes. Depending on the selection of the first
drop-down box, the second drop-down box is either disabled or enabled.
The problem is on these dynamically created rows. Here is the code for
the dynamically created first drop-down:
var cell = row.insertCell(0);
var elSelect = document.createElement('select');
elSelect.setAttribute('name','country[' + regionNumber + ']');
elSelect.setAttribute('id','country[' + regionNumber + ']');
elSelect.setAttribute('onchange','changeCountry(regionNumber)');
regionNumber is a variable that gets 1 added to it every time this
function runs.
As you can see, there is an onchange event handler. The problem is if I
make the onchange occur, it uses the current value of regionNumber, but
I want it to use the value that regionNumber was when that setAttribute
code ran.
Can anyone help me? If I need to further explain, please tell me so.