View Full Version : Determining which <option> has focus

08-11-2004, 03:45 AM
Please help - I was wondering if anyone knows how to determine in Javascript which option of a select currently has the focus (as opposed to which item is selected).

The reason for this requirement is :

I have a select field on my page that has a fixed width (and cannot be changed), and the text for some options is too long so that the text is truncated and the user cannot see it all.

As the user moves the mouse over the options in the select field, after a small delay, I want to have a small popup window appear that displays the full text of the options.

The only difficult thing about this is - during the select's onmousemove event, I need to know what option currently has the focus.

Is this possible? Does anyone have a better solution???


08-11-2004, 04:24 AM
This works in Gecko browsers (NS7, Mozilla, Firefox)

<option title="This is item 1">item 1</option>
<option title="This is item 2">item 2</option>

onmouseover/onmouseout events are also supported.

08-11-2004, 04:45 AM
thanks for your response glenngv

08-11-2004, 04:53 AM
Feel sorry that IE doesn't support that very basic thing in option tags. :(

You will need to create a custom widget that looks like a dropdown in order to make it work in IE. I think I've seen something like that here in CF. I think someone posted it, something like editable dropdown script.

08-11-2004, 05:07 AM
I saw it! :)


I was correct it was Vladdy who made it. :)

08-11-2004, 05:14 AM
thanks for that, it will work a treat i think

definately is some spiffy code there by Vladdy