Quote:
Originally Posted by VIPStephan
Well, lacking a satisfying solution I ended up putting the option into the HTML rather than adding it with JS. Apparently there is no way to check for the attribute, not for the state. Thanks for your thoughts, though.
|
you should be able to check the <select>'s selectedIndex instead of checking each option. you only need to check each option when the attrib "
multiple" is used on the <select>.
also note that you can use
option.getAttribute("selected") or even
hasAttribute instead of
option.selected to differentiate between the state and the attribs. Normally however, state and attribs are synced; but NOT ALWAYS!
finally, i think
option.selected should be set to true, not sure how every browser handles a string setting...