Forum Moderators: open
I put together this handy reference for versions of javascript, jscript and ecmascript [webmasterworld.com] a while back. Hope it helps you.
from js book
in JS 1.0 text value of option is read only ..
in JS 1.1 and up it is settable.
or mbe im just missing something.. i am pretty knackered..
function clearselect(field){
for (i = field.options.length; i >= 0; i--) {
if(isNN == true){
field.options[i].text = '';
}else{
field.options[i] = null;
}
}
}
as you may have found. doing this .. when i want to refill the field, NN4 gives the depth of the dropdowns no depth..
something that im missing?!
cheers again
Or, whenever possible use the universal this to pass the correct value for each individual browser.
In any case, your sample code looks like it is attempting to modify only the VALUE of a form's <OPTION>. DrDoc is probably on the right path when he suggests you really need to modify the innerHTML/layer contents entirely so not only will the <OPTION> value be updated, the user will see the new value in the OPTIONs list on the page as well. Sadly, in NS4, this can only be done in a absolutely-positioned <DIV>. I use code like this to write HTML:
function writeMe(theWindow,id,theText) {
if (document.getElementById) { // NS6+, IE5.5+
theWindow.document.getElementById(id).innerHTML = theText;
} else if (document.all) { // IE4+
theWindow.document.all[id].innerHTML = theText;
} else if (document.layers) { // NS4 ONLY!
theElement = theWindow.document.layers[id].document;
theElement.open(); // open document
theElement.write(theText); // write to document
theElement.close(); // close document
} // endif browser branches
} // end writeMe
So, you'd be setting theText to something like:
theText = "<option value=\"" + newValue + "\">" +
newOptionLabel + "</option>";
and then call writeMe(); with the appropriate values. Good luck!