Am a bit new to javascript. This question might sound a bit too silly, but I'm not able to figure it out why the following doesn't work in IE and works in firefox..
<select multiple="multiple">
<option value="tx" onClick="alert('tx');">Texas</option>
<option value="ak" onClick="alert('ak');">Alaska</option>
<option value="ca" onClick="alert('ca');">California</option>
<option value="ws" onClick="alert('ws');">Washington</option>
<option value="tn" onClick="alert('tn');">Tennessee</option>
</select>
The alert doesn't come up in IE (I'm using IE8). But it works in firefox!!!!!
I would use the onchange event:
Although Daniel Mendel's solution is perfectly valid.
According to w3schools, the option tag does support an onclick attribute. I tried with with bottom of the barrel IE6 and this doesn't seem to be the case.
The simplest way to do this would be:
This is not exactly what you are after, but should be pretty close.
EDITS
It would just take more work:
At this point it would be appropriate to wrap the onchange into a function in a js file instead of embedding it in the html.
This is because IE doesn't register a click event when you select a new option in a select field (guessing). Instead, you should use the onBlur event (and put the code into your javascript instead) like so (assuming jQuery):