...

View Full Version : Determining which <option> has focus



wopdvg
08-11-2004, 02: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???

Thanks
Daniel

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

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

onmouseover/onmouseout events are also supported.

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

glenngv
08-11-2004, 03: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.

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

http://www.codingforums.com/showthread.php?t=14300

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

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

definately is some spiffy code there by Vladdy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum