`
阅读更多
<!-- Created by TopStyle Trial - www.topstyle4.com -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<script type="text/javascript">

function checkAll(input1,input2){

  var allcheck =   document.forms[input1];
  var str='';
  var lengthall = allcheck.length;
  for(var count=0; count < lengthall ; count++){
       if(input2.checked == true){
       if(allcheck.elements[count].type == "checkbox"){
       allcheck.elements[count].checked= true;
       if(str != ''){
       str += allcheck.elements[count].value+",";
       }else{
       str= allcheck.elements[count].value+","
       }
        
       }
       }else{
       if(allcheck.elements[count].type == "checkbox"){
       allcheck.elements[count].checked= false;
       }
       }
  }
  alert(str);
}


</script>
<body>
<input type="checkbox" onclick="checkAll('testForm',this)">
   <form id="testForm" name="testForm">
      <input type="checkbox" value="1">
      <input type="checkbox" value="2">
      <input type="checkbox" value="3">
      <input type="checkbox" value="4">
      <input type="checkbox" value="5">
   </form>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics