stylesheet for combo box

Posted on 2006-04-02
Last Modified: 2010-04-09
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" different color...and "11111", "222222" different color...

Thanks in advance...
Meenakshi Dhar
Question by:MeenakshiDhar
    LVL 16

    Accepted Solution

    Each item will have to be one color.

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

    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>

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


    Author Comment

    Ok is it not possible at all?? I mean any other way to do it.....
    LVL 9

    Expert Comment

    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.
    LVL 6

    Expert Comment

    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
              Response.write "yourvalue"))
    LVL 6

    Expert Comment

    then it means you could only have one color for each option as others told u

    Author Comment

    yes.. sara110 is right...

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now