html+js动态选中

来源:互联网 发布:linux root 密码修改 编辑:程序博客网 时间:2024/05/29 14:28
<html>
 <head>
  <script>
   function chan(obj){
    if(obj.value==1){
     document.getElementById("check1").checked=true;
    }else if(obj.value==2){
     document.getElementById("check2").checked=true;
    }else if(obj.value==3){
     document.getElementById("check3").checked=true;
    }else{
     document.getElementById("check4").checked=true;
    }
   }
  </script>
 </head>
 <body>
  
    <b>您的姓名:</b>
    <input type="text" style="width:150px"></br>
    <b>电子邮件:</b>
    <input type="text" style="width:150px"></br>
    <b>您购买书的途径:</b>
       <select onchange="chan(this)">
        <option value="1">请选择...</option>
        <option value="1">内容新</option>
        <option value="2">示例丰富</option>
        <option value="3">内容有一点深度</option>
        <option value="4">比较实用</option>
       </select></br> 
    <b>您认为本书最大的特色在于:</b></br>
    <input type="checkbox" id="check1" name="check1" />内容新</br>
    <input type="checkbox" id="check2" name="check2" />示例丰富</br>
    <input type="checkbox" id="check3" name="check3" />内容有一点深度</br>
    <input type="checkbox" id="check4" name="check4" />比较实用</br>
    是否需要在本书再版时立即通知您:
    <input type="radio" id="radio1" name="radio" checked/>是
    <input type="radio" id="radio2" name="radio" />否
    </br>
    其他意见和评论:</br>
    <textarea name="t1" cols="50" rows="6" ></textarea>
    
 </body>
</html>
原创粉丝点击