checxbox 全选之2

来源:互联网 发布:mysql复制整个数据库 编辑:程序博客网 时间:2024/04/30 03:25

<html>
<body> 
<script  language="javascript"> 
       function  selectAll() 
       { 
       var  arrObj  =  document.form1.checkbox1; 
       for(var  i  =  0;  i  <  arrObj.length;i++) 
       { 
 
                               if(typeof  arrObj[i].type  !=  "undefined"  &&  arrObj[i].type=='checkbox')  arrObj[i].checked  =true; 
       } 
       } 
 
       function  unSelectAll() 
       { 
           var  arrObj  =  document.form1.checkbox1; 
       for(var  i  =  0;  i  <  arrObj.length;i++) 
       { 
                               if(typeof  arrObj[i].type  !=  "undefined"  &&  arrObj[i].type=='checkbox')  arrObj[i].checked  =false; 
       } 
       } 
</script> 
 <form name="form1">
<input  type=checkbox  name=checkbox1  value="1"> d  
<input  type=checkbox  name=checkbox1  value="2">  d
<input  type=checkbox  name=checkbox1  value="3"> 
<input  type=checkbox  name=checkbox1  value="4"> 
<input  type=checkbox  name=checkbox1  value="5"> 
<input  type=checkbox  name=checkbox1  value="6"> 
<input  type=checkbox  name=checkbox2 value="41"> 2
<input  type=checkbox  name=checkbox2  value="278">  2
<input  type="button"  value="全选"  onClick="selectAll()"> 
<input  type="button"  value="全部不选"  onClick="unSelectAll()"> 
</form>
</body> 
</html>  

 

原创粉丝点击