Set a background color for options in combo box
Moderator: General Moderators
Set a background color for options in combo box
I have a combobox, how to set a background color for a specified option. For example the option red to have Red background color etc.... I have searched a lot in google, but I didn't have any good results.
- akuji36
- Forum Contributor
- Posts: 190
- Joined: Tue Oct 14, 2008 9:53 am
- Location: Hartford, Connecticut
Re: Set a background color for options in combo box
It sounds like you may need css.
Do you want to see the desired colored change
when a selection is made from a list of options
in your combo box?
Do you want to see the desired colored change
when a selection is made from a list of options
in your combo box?
-
maneetpuri
- Forum Commoner
- Posts: 60
- Joined: Tue Oct 07, 2008 6:32 am
Re: Set a background color for options in combo box
HI,
Just define the background color in Option tag.
<select name="">
<option>Select Color</option>
<option style="background-color:red; color:#FFF">RED</option>
<option style="background-color:green; color:#FFF">GREEN</option>
<option style="background-color:black; color:#FFF">BLACK</option>
</select>
Hope This Helps,
Cheers
Just define the background color in Option tag.
<select name="">
<option>Select Color</option>
<option style="background-color:red; color:#FFF">RED</option>
<option style="background-color:green; color:#FFF">GREEN</option>
<option style="background-color:black; color:#FFF">BLACK</option>
</select>
Hope This Helps,
Cheers
Re: Set a background color for options in combo box
Ya, you have to use CSS. The last I checked though, this doesn't work in Firefox.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Set a background color for options in combo box
thnx maneetpuri, this Worked for me 