| Author |
Multicolor combo box in JSP/HTML
|
Aditya Bhanose
Greenhorn
Joined: Nov 26, 2008
Posts: 5
|
|
I want to create a combobox in html where each word in each selection is a different color. The following code makes an option in the combo box red: <option style="color: #FF0000">Combo option</option> However, I would like the word "Combo" to be red, and the word "option" to be green. I've tried the following: <option style="color: #FF0000">Combo <span style="color: #00FF00">option</span></option> and also: <option><span style="color: #FF0000">Combo</span> <span style="color: #00FF00">option</span></option> but neither worked.
|
 |
Duc Vo
Ranch Hand
Joined: Nov 20, 2008
Posts: 254
|
|
|
Not sure why you want to have it that way, but I'm sure you can't do it with standard select box. You may want to try to write your own select box with with css & javascript or use flash.
|
“Everything should be as simple as it is, but not simpler.” Albert Einstein
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2552
|
|
Welcome to Javaranch Aditya Bhanose Please choose an appropriate forum for your questions.Asking questions in an unrelated forum yields fewer and less useful response. Read this for more information.
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
Aditya Bhanose
Greenhorn
Joined: Nov 26, 2008
Posts: 5
|
|
I need to display two diffrent values in the select box. <option><%=lang.getName()%> <%=lang.getShortName()%> </option> In this it becomes difficult for user to diffrentiat both the values. Putting a separater(-) is also not that helpful. I am looking for solution where user can easyly see both the values. I have data like: United States Of America USA India Ind South Africa SA You can see first value in each row is not of fixed width, and Its difficult to understand which is short name (2nd value).Is there any way we can give fixed width to values in option?
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
FYI: HTML does not have a combobox You can not style the text differently inside of the option tag. It is all or nothing. For the fixed width, you would have to put whitespace manually into it. [That is if the select element will honor it and not trim it.] Eric
|
 |
Aditya Bhanose
Greenhorn
Joined: Nov 26, 2008
Posts: 5
|
|
I think I should go with using separator or manually adding spaces between the words. Thanks For Reply -Aditya [ November 26, 2008: Message edited by: Aditya Bhanose ]
|
 |
 |
|
|
subject: Multicolor combo box in JSP/HTML
|
|
|