Click to See Complete Forum and Search --> : Attach event to options in select element
ankitforjava
04-27-2007, 05:17 PM
Hi,
I would like to do something like this using javascript and/or css
<select>
<option onmouseover="alert('something1')">something1</option>
<option onmouseover="alert('something2')">something2</option>
</select>
This works in Firefox but not in IE 6. Can someone please suggest a fix for this?
felgall
04-27-2007, 06:28 PM
The options are part of the select element. Attaching events to a part of an element doesn't make sense. Your code is invalid. Put the event on the select and then test which option is selected.
ankitforjava
04-27-2007, 07:01 PM
I need to capture value of the "option" when you mouseover on option. How can I achieve this for IE?
You dont attach events to the option list but you can attach an event to the option list header, you would use the onChange="" tag and put the reference tothe function your calling.
ankitforjava
04-28-2007, 06:58 AM
Can you give me an example of how to do this?
Logic Ali
04-28-2007, 07:26 AM
Can you give me an example of how to do this?If I understand, you want to generate captions for each hovered option.
As you have found, only FireFox provides events for individual options and the onchange event does not occur until an option is clicked.
You would need to use a pulldown menu script, modified to generate captions as the links are hovered, backed-up by a normal select box for browsers that could not support such a menu.
ankitforjava
04-28-2007, 08:10 AM
Can you show me a sample code?