By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,769 Members | 1,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,769 IT Pros & Developers. It's quick & easy.

Option onclick does not fire for IE

P: n/a
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.

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<Je*******@aol.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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>
Jul 23 '05 #2

P: n/a

Je*******@aol.com wrote:
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.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.