<html>
<head>
<title>Demo</title>
<script language="javascript">
<!--
function change(){var src = document.getElementById("src");
var value = src.value.toLocaleLowerCase();
if(value==red)
{
document.bgColor = 0xff0000;
}
else if(value==blue){
document.bgColor = 0x0000FF;
}
else if(value==green){
document.bgColor = 0x00ff00;
}
}
-->
</script>
</head>
<body onLoad="resetColor()">
<select name="b1" id="src" >
<option>red</option>
<option>blue</option>
<option selected>green</option>
</select>
<input type="button" onClick="change()" value="改变颜色">
</body>
</html> 

解决方案 »

  1.   

    <html>
    <head>
    <title>Demo</title>
    <script language="javascript">
    function change(){var src = document.getElementById("src");
    var value = src.value.toLocaleLowerCase();
    alert(value);
    if(value=='red')
    {
    document.bgColor = 0xff0000;
    }
    else if(value=='blue'){
    document.bgColor = 0x0000FF;
    }
    else if(value=='green'){
    document.bgColor = 0x00ff00;
    }
    }
    </script>
    </head>
    <body>
    <select name="b1" id="src" >
    <option value="red">red</option>
    <option value="blue">blue</option>
    <option value="green" selected >green</option>
    </select>
    <input type="button" onClick="change()" value="改变颜色">
    </body>
    </html> 
      

  2.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript">
    function checkColor(){
     var list = document.forms[0].checkGround;
     document.bgColor = list.options[list.selectedIndex].value;
    }
    </script>
    </head><body>
    <form>
     <select name="checkGround" onChange="checkColor()">
       <option value="red">红
       <option value="yellow">黄
       <option value="green">绿
     </select>
    </form>
    </body>
    </html>