[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

stylesheet for combo box

Hi All,
I have one combobox in my form.
The contents are displayed in the following manner in the combobox :

Test1   (AAAAA)   -- 11111
Test2   (BBBBBB)   -- 22222
Test3   (CCCCCC)   -- 333333
Test4   (DDDDDD)   -- 444444
Test5   (EEEEEE)   -- 555555

..... so on

I want to display Test1, Test2, Test3... in different colors...Similarly "AAAAAA", "BBBBBB", "CCCCCC"...in different color...and "11111", "222222" ...in different color...

Thanks in advance...
Meenakshi Dhar
0
MeenakshiDhar
Asked:
MeenakshiDhar
1 Solution
 
sam85281Commented:
Each item will have to be one color.

All of: Test1   (AAAAA)   -- 11111 can be red
All of: Test2   (BBBBBB)   -- 22222 can be blue
etc....

But you can't do: Test1(in red) (AAAAAA)in blue --111111(in green)

To change the item color you just add a color style to <option>

i.e.
<option value="blah" style="color: #cccccc">blah</option>

-Sam
0
 
MeenakshiDharAuthor Commented:
Ok is it not possible at all?? I mean any other way to do it.....
0
 
smaccariCommented:
sam is right, you can only change the color of options tags.
No way to put two different colors in a single option tag.
If you really want to do so, you will have to make your own custom combo-like control with JavaScript/CSS.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
sara110Commented:
if you fill your data from database and your page is for instance asp  you could do like this , and define array of colors and set it for each data which you read from database instead of fixed color which I used in below (  "color:black"   )
"color:" & arr(1)

<select size="19" class="MT" name="D1"  style="border: 0px solid #285007; padding: 0; background-color: #EEEEEE; scrollbar-highlight-color:#00ff00; scrollbar-base-color:green ; font-weight:bold" >

<%
          while NOT RS.EOF%><option
          style=<%
         "color:black"  
          value="<%
          Response.write "yourvalue"))
             %>">
   </option><%
           RS.MoveNext
          WEND
          %>
 </select>
0
 
sara110Commented:
then it means you could only have one color for each option as others told u
0
 
MeenakshiDharAuthor Commented:
yes.. sara110 is right...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now