+ -
当前位置:首页 → 问答吧 → 求助~单选按钮控制复选框的问题

求助~单选按钮控制复选框的问题

时间:2011-11-25

来源:互联网

如下代码,是可以做到的
VBScript code

<script>
function testClk(){

  if(form1.radio1.checked==true)
    form1.ou_user.disabled = false;
  else
   form1.ou_user.disabled = true;
}

</script>
<form id="form1" name="form1" method="post" action="">
 


     <input type="radio" name="o_status" id="radio1" value="1" onclick="testClk()"  />
      通過  
        &nbsp; 
         <input type="radio" name="o_status" id="radio2" value="0" onclick="testClk()"  />
         駁回

  
      <input type="checkbox" name="ou_user" id="ou_user" disabled="disabled" />
      
      
</form>




但是我加了个循环就不行了,如下

VBScript code

<script>
function testClk(){

  if(form1.radio1.checked==true)
    form1.ou_user.disabled = false;
  else
   form1.ou_user.disabled = true;
}

</script>
<form id="form1" name="form1" method="post" action="">
 


     <input type="radio" name="o_status" id="radio1" value="1" onclick="testClk()"  />
      通過  
        &nbsp; 
         <input type="radio" name="o_status" id="radio2" value="0" onclick="testClk()"  />
         駁回

   <% for i=1 to 5%>
      <input type="checkbox" name="ou_user" id="ou_user" disabled="disabled" />
      
      <%next%>
</form>

作者: shugeer   发布时间: 2011-11-25

JScript code
function testClk(){

  if(form1.radio1.checked==true){
      var all=document.getElementsByName('ou_user'),length=all.length;
      while(length-->0)
          all[length].disabled=false;
  }
  else{
      var all=document.getElementsByName('ou_user'),length=all.length;
      while(length-->0)
          all[length].disabled=true;
  }
}


用document.get来获取元素 不要通过form.

作者: ifandui   发布时间: 2011-11-25

相关阅读 更多

热门下载

更多