Wednesday, February 11, 2009

Javascript "Option" object not fully-functional in IE6

This is related to the previous post. In IE6, the following javascript command doesn't actually select the newly-created option for a drop-down:
myselect.options[myselect.options.length]=new Option("optionvalue", "optiontext", false, true);
Instead, you'll need to specify to select this afterwords using something like:
myselect.options[myselect.options.length]=new Option("optionvalue", "optiontext");
myselect.options[myselect.options.length-1].selected = true;

No comments:

Post a Comment