checkbox 的allchose和antichose

来源:互联网 发布:递推算法 编辑:程序博客网 时间:2024/06/08 20:14


 

<html>

<head>

<script>

functionantichose()

{for(i=0;i<form1.checkbox.length;i++)

  {s="document.form1.checkbox["+i+"].click();";

   eval(s);}

}

functionallchose()

{for(i=0;i<form1.checkbox.length;i++)

 {s="document.form1.checkbox["+i+"].checked=true;";

   eval(s);}

}

</script>

</head>

<body>

<formname=form1>

<inputtype=checkbox  name=checkbox>

<inputtype=checkbox  name=checkbox>

<inputtype=checkbox  name=checkbox>

<inputtype=checkbox  name=checkbox>

<inputtype=button  onclick="allchose();"value="全选">

<inputtype=button onclick="antichose();" value="反选">

</form>

</body>

</html>

原创粉丝点击