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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select form field color change onFocus

Status
Not open for further replies.

bugsville

IS-IT--Management
Dec 2, 2002
1
US
I am currently attempting to setup a form <select> object that, when clicked on will display the options in a different color, then revert back to white when an option is chosen. I am using the following code:

<form name=&quot;form1>
<select name=&quot;ManID&quot; onFocus=&quot;this.style.backgroundColor='e8e2c6'&quot; onBlur=&quot;this.style.backgroundColor='ffffff'&quot;>
<option selected value=&quot;Any&quot;> </option>
<option value=&quot;manufacturerID&quot;>ManufacturerName
<option value=&quot;manufacturerID2&quot;>ManufacturerName2
</select>
</form>

However, it is very quirky, and doesnt change the color until you;ve either clicked on the pulldown first or you click on the pulldown and scroll throguh (focusOn) the options.

I have also tried the following javascript:
<script language=&quot;javascript&quot;>

function manOnColor(){
for (i = 0; i < document.form1.ManID.length; i++) {
document.form1.ManID.style.background='e8e2c6'}
}

function manOffColor(){
for (i = 0; i < document.form1.ManID.length; i++) {
document.form1.ManID.style.background='ffffff'}
}

</script>

As well as applying the onfocus, onblur to the option fields themselves and trying onChnage... Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top