T
Tyrone Slothrop
It is a familiar story. It works in Firefox, but not in IE.
I want to dynamically populate a select box with an array of values
based upon the value selected from another select. The arrays are
defined when the page is loaded.
Assuming that the arrays are name a, b. and c:
<select name="someArray">
<option onclick="selArr(a);" value="a">A</option>
<option onclick="selArr(b);" value="b">B</option>
<option onclick="selArr(c);" value="c">C</option>
</select>
function selArr(whichArr) {
var optStr;
var cnt = whichArr.length;
for (var i=0; i<cnt; i++) {
optStr += '<option value="'+whichArr.k+'
'+whichArr.v+'">'+whichArr.k+' '+whichArr.v+'</option>\n';
}
document.getElementById('sel2').innerHTML = optStr;
}
I have run into this before where IE ignores any calls to a function
from an option value. However, the problem is if I call the function
from the select tag:
<select name="someArray" onchange="selArr[this.value);">
this.value is treated not as the defined array but as a var value, as
if is enclosed by quotes.
Any ideas how to get around this?
TIA!
I want to dynamically populate a select box with an array of values
based upon the value selected from another select. The arrays are
defined when the page is loaded.
Assuming that the arrays are name a, b. and c:
<select name="someArray">
<option onclick="selArr(a);" value="a">A</option>
<option onclick="selArr(b);" value="b">B</option>
<option onclick="selArr(c);" value="c">C</option>
</select>
function selArr(whichArr) {
var optStr;
var cnt = whichArr.length;
for (var i=0; i<cnt; i++) {
optStr += '<option value="'+whichArr.k+'
'+whichArr.v+'">'+whichArr.k+' '+whichArr.v+'</option>\n';
}
document.getElementById('sel2').innerHTML = optStr;
}
I have run into this before where IE ignores any calls to a function
from an option value. However, the problem is if I call the function
from the select tag:
<select name="someArray" onchange="selArr[this.value);">
this.value is treated not as the defined array but as a var value, as
if is enclosed by quotes.
Any ideas how to get around this?
TIA!