<input type=button name="a" onclick="changecolor(this,'blue')">
<script>
function changecolor(inputbox, inputcolor){
inputbox.style.background=inputcolor;}
</script>

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="JavaScript" type="text/JavaScript">function change(){
    var u=0
    var a=document.getElementsByName("radio1")
    for(i=0;i<a.length;i++)
    {
     
      if(a[i].checked){u=a[i].value}
    }switch(parseInt(u)){
    case 1:
    document.bgColor="#ff0000"
    break;
    case 2:
    document.bgColor="#ffff00"
    break;
    case 3:
    document.bgColor="#00ff33"
    break;
    }}</script></head><body><form action="" method="post" name="form1">
    <input name="radio1" type="radio" value="1">a
    <input name="radio1" type="radio" value="2">b
    <input name="radio1" type="radio" value="3">c
    <input name="button" type="button" onClick="change()" value="change1">
    </form>
    </body>
    </html>