#1
  1. No Profile Picture
    Still learning...
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Cheshire, UK
    Posts
    58
    Rep Power
    12

    CSS Styles for <Select> list


    Hello

    I need to know, if its possible using CSS or JS to..

    Have alternating colours in a select list. Not a drop down menu, a select list which will have multiple selections.

    One thing I should mention, the contents of the list are PHP dynamic... Im sorry if this isn't a post for this forum.

    Thank you in advance....
    ... shamone! ...

    -

    Welcome to DevShed!

    How to post questions | MySQL Website | PHP Website | Always lewk before posting
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2003
    Location
    Italy, EU
    Posts
    517
    Rep Power
    12
    I think that if you're using PHP you can set the colors while generating the code...
    Post your code or send it!!
    Cheers, Dave
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    249
    Rep Power
    11
    Yes, you can define a css class for the option tag:
    option.classname
    { color:
    background-color ;
    }

    then generate option tags like this
    <option class="<? echo classname; ?>">

    http://galileo.spaceports.com/~ibidris/
  6. #4
  7. No Profile Picture
    Still learning...
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Cheshire, UK
    Posts
    58
    Rep Power
    12
    Originally posted by magma
    I think that if you're using PHP you can set the colors while generating the code...
    Post your code or send it!!
    Ahh yes, my code is

    PHP Code:
    <select name="Industry_Org_Type[]" size="4" multiple id="select">
    <option value="Industry / Org" selected>-- Organisation Type --</option>
    <?php do {  ?>
    <option value="<?php echo $row_rsDropDown2['Org Code']?>"><?php echo $row_rsDropDown2['Organisation Type']?></option>
    <?php
    } while ($row_rsDropDown2 mysql_fetch_assoc($rsDropDown2));
      
    $rows mysql_num_rows($rsDropDown2);
      if(
    $rows 0) {
          
    mysql_data_seek($rsDropDown20);
          
    $row_rsDropDown2 mysql_fetch_assoc($rsDropDown2);
      }
    ?></select>
    ... shamone! ...

    -

    Welcome to DevShed!

    How to post questions | MySQL Website | PHP Website | Always lewk before posting
  8. #5
  9. No Profile Picture
    Still learning...
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Cheshire, UK
    Posts
    58
    Rep Power
    12
    Originally posted by ibidris2003
    Yes, you can define a css class for the option tag:
    option.classname
    { color:
    background-color ;
    }

    then generate option tags like this
    <option class="<? echo classname; ?>">

    http://galileo.spaceports.com/~ibidris/
    What about alternating the rows? Ie, one row white, the next blue, and so on and so forth
    ... shamone! ...

    -

    Welcome to DevShed!

    How to post questions | MySQL Website | PHP Website | Always lewk before posting
  10. #6
  11. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2003
    Location
    Italy, EU
    Posts
    517
    Rep Power
    12
    You can define two classes like:
    Code:
    .bg1 {
        background-color: green;
    }
    .bg2 {
        background-color: lime;
    }
    ...and then...


    PHP Code:
    <?php
    $boo 
    0;
    do {
    if(
    $boo$aClass "class='bg1'";
    else  
    $aClass "class='bg2'";
    $boo=!$boo;
    ?>
    <option <?php echo $aClass?> value="<?php echo $row_rsDropDown2['Org Code']?>"><?php echo $row_rsDropDown2['Organisation Type']?></option>
    I don't know if this is the easiest way, but should work!!
    Last edited by magma; August 27th, 2003 at 08:12 AM.
    Cheers, Dave

IMN logo majestic logo threadwatch logo seochat tools logo