Jump to content

[SOLVED] Hey


burnside

Recommended Posts

Hi i was woundering is it possable to change the color of a drop down menu? Ill try explane ,

<select>
  <option>red</option>
  <option>blue</option>
  <option>black</option>
</select>

is it possable to like change the background of the option? If you get what im trien to say sorry im not to good at explaning

Link to comment
Share on other sites

yeah sumit like that, i mean say for example, if a option was :

 <select>
  <option>high</option> <---- background red
  <option>medium</option> <---- background green 
  <option>low</option> <----  background yellow
</select>

 

if yo know what im trien to say hahaha

Link to comment
Share on other sites

Something simple that will change the background on your page when different level is selected

 

<html>
<script language="JavaScript">
<!--


var Color = new Array(); 

Color[1] = '#FF0000';
Color[2] = '#00FF00';
Color[3] = '#FFFF00';



function changeBG(myColor){
document.bgColor = Color[myColor];
}

//-->
</script>
<select name="d"  onChange="javascript:changeBG(this.value)">
  <option value="1">High</option> <---- background red
  <option value="2">Medium</option> <---- background green 
  <option value="3" selected>Low</option> <----  background yellow
</select>
</body>
</html>

Link to comment
Share on other sites

Not really anything to do with PHP...but =P

 

<select>
  <option style="background:#ff0000; color:#000000;">Red</style>
  <option style="background:#0000a0; color:#000000;">Blue</style>
  <option style="background:#000000; color:#FFFFFF;">Black</style>
</select>

 

Maybe something like that is what you're looking for?

Link to comment
Share on other sites

This is the closest I've gotten to what I think the OP wants to do:

<html>
<head>
<title>Option Color Test</title>
<style>
.option_red {
        background-color:red;
        color: white;
}
.option_blue {
        background-color: blue;
        color: white;
}
.option_black {
        background-color: black;
        color: white
}
</style>
</head>
<body>
<form method="post">
<select name="test_color">
  <option></option>
  <option>Normal</option>
  <option class="option_red">red</option>
  <option class="option_blue">blue</option>
  <option class="option_black">black</option>
</select>
</form>
</body>

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.