Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight a SELECT drop-down list onFocus

Status
Not open for further replies.

jgannaway

Programmer
Jan 28, 2005
4
US
Here's my code:

Code:
<select id="fruit" name="fruit" onfocus="this.style.backgroundColor='rgb(255,253,216)';" onblur="this.style.backgroundColor='';">
<option>apple</option>
<option>orange</option>
</select>
When a user clicks on the Drop Down List, here are the results:
In Mozilla: The box highlights in yellow (background color) AND the option list that displays also has a yellow highlight.

In IE: The box highlights in yellow, BUT the option list does not! The option list has a white background color UNTIL the user mouses over the option -- THEN it turns yellow.

How can I get this work in IE like it does in Mozilla?

Thanks!
-Jeff

"Grace... She travels outside of Karma"
-U2
 
this works in IE except that you need to move your mouse on the options (its onfocus of options)
 
i would try something like this:

Code:
function doChange(s) {
    s.style.backgroundColor = (s.style.backgroundColor=='red')?'':'red';
}

Code:
<select name="s" onfocus="doChange(this);" onblur="doChange(this);">



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top