Option onclick does not fire for IE

J

JehanNYNJ

I have found that the onclick does not fire for Option elements in IE.
Clicking on an option only fires the Select's onclick. Can someone
please confirm this?

If it is so then how would we best implement a case where only some of
the options in a select should trigger the onclick?

Thanks in advance for any input.
 
M

McKirahan

I have found that the onclick does not fire for Option elements in IE.
Clicking on an option only fires the Select's onclick. Can someone
please confirm this?

If it is so then how would we best implement a case where only some of
the options in a select should trigger the onclick?

Thanks in advance for any input.


Test in the select's onclick:

<html>
<head>
<title>optClick.htm</title>
<script type="text/javascript">
function clicker(that) {
var pick = that.options[that.selectedIndex].value;
if (pick == "2") alert("Hello World");
}
</script>
</head>
<body>
<form>
<select name="sel" onclick="clicker(this)">
<option value="1">One
<option value="2">Two
<option value="3">Three
</select>
</form>
</body>
</html>
 
R

RobB

I have found that the onclick does not fire for Option elements in IE.
Clicking on an option only fires the Select's onclick. Can someone
please confirm this?

If it is so then how would we best implement a case where only some of
the options in a select should trigger the onclick?

Thanks in advance for any input.

Option objects in MSIE have zero event handlers. Processing of
listboxes is generally done via the Select.onchange handler, and the
Select.selectedIndex property (which holds the index of the currently
selected option). Presumably you can accomplish whatever you need to
using this approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top