[Javascript] IE verses the option element onclick event

Brian L. Matthews blmatthews at gmail.com
Fri Dec 30 13:05:36 CST 2005


>Suggestions of where to look for a QaD answer of how to determine 
>which <option /> was selected when the onchange event fires for the 
><select />.

Given

sel = document.getElementById('selectElementId');

then sel.selectedIndex is the the index into sel.options of the 
currently selected option. So when onchange fires on the select 
element, sel.options[sel.selectedIndex] is a reference to the Option 
instance of the selected option.

And as an aside, I don't know that onchange on the option not firing 
is a bug. The value of the option isn't changing if you select it or 
select a different one, it's the value of the select that's changing, 
so I'd expect its onchange to fire, as it does.

Hope this helps.

Brian



More information about the Javascript mailing list