hi all,
i'm trying to do something that i assume is common, to have a select control with a list of options, and then to update that list of options based on user action.
my problem is, i'm using innerHTML to initialize and change the list of options, but for some reason the first "<option value='1'>" part of the new HTML is getting cut off.
here is the section of code for changing it. any thoughts? uList is the id for the HTML select tag. uList is also the name of a javascript array of objects with member properties including "sName".
if the array of uList.sName's include "zero" and "one", then the desired result for innerHTML would be...
instead, i'm getting...
thanks,
glenn
i'm trying to do something that i assume is common, to have a select control with a list of options, and then to update that list of options based on user action.
my problem is, i'm using innerHTML to initialize and change the list of options, but for some reason the first "<option value='1'>" part of the new HTML is getting cut off.
here is the section of code for changing it. any thoughts? uList is the id for the HTML select tag. uList is also the name of a javascript array of objects with member properties including "sName".
Code:
function initList() {
document.getElementById("uList").innerHTML = "";
for (i=0;i<uList.length;i++) {
document.getElementById("uList").innerHTML += "<option value='" + i + "'>" + uList[i].sName + "</option>";
}
}
if the array of uList.sName's include "zero" and "one", then the desired result for innerHTML would be...
Code:
<option value='0'>zero</option><option value='1'>one</option>
instead, i'm getting...
Code:
zero</option><option value='1'>one</option>
thanks,
glenn