Javascript, IE and mouseover on select, option.
-
Hiya all. I stumpled on a problem one of my coworkers were having today, in that he'd like to fire an onMouseOver event on each option in a select-object. What ideally would should happen was that an image would be changed when the mouse hovers over the options in a select. This can be done with FireFox, but not with IE, by using onMouseOver on each option. something along this line: Option 1 Option 2 Now this works in FireFox, but unfortunally in IE, which is what the client is going to use. Does anybody know of a work-around or possible alternative implementation to this problem? With regards --------------------------- 127.0.0.1 - Sweet 127.0.0.1
-
Hiya all. I stumpled on a problem one of my coworkers were having today, in that he'd like to fire an onMouseOver event on each option in a select-object. What ideally would should happen was that an image would be changed when the mouse hovers over the options in a select. This can be done with FireFox, but not with IE, by using onMouseOver on each option. something along this line: Option 1 Option 2 Now this works in FireFox, but unfortunally in IE, which is what the client is going to use. Does anybody know of a work-around or possible alternative implementation to this problem? With regards --------------------------- 127.0.0.1 - Sweet 127.0.0.1
Hi, You can perform the check in the select onChange event. Something like this:
function selectExp() { alert(document.getElementById('ddlTest').options[document.getElementById('ddlTest').selectedIndex].value); } first second third fourth fifth sixth seventh eighth ninth tenth
This wey you get the selected index or its value , accordingly you can put the code for different options. I hope this works for you. Thanks Sushant Duggal. -
Hi, You can perform the check in the select onChange event. Something like this:
function selectExp() { alert(document.getElementById('ddlTest').options[document.getElementById('ddlTest').selectedIndex].value); } first second third fourth fifth sixth seventh eighth ninth tenth
This wey you get the selected index or its value , accordingly you can put the code for different options. I hope this works for you. Thanks Sushant Duggal.Thanks for the reply. The problem is that onChange dosen't fire until after the selection has been changed in which case the page changes, whereas the onMouseOver in Firefox would trigger as you use your mouse to "scroll" down the selection-choices, and you'd be able to see a preview before making the selection. I am "fearing"/thinking that we do need to go with an "onChange" to have compatibility with Internet Explorer, but seeing as this was a client request (*sigh*) I thought it was worth to see if there was a workaround for IE, to mimic the behaviour we see in Firefox. But thanks for your reply. With regards. --------------------------- 127.0.0.1 - Sweet 127.0.0.1