码迷,mamicode.com
首页 > Web开发 > 详细

全选反选取消-js代码

时间:2014-07-23 22:17:07      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   java   color   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function selectAll(){
    var inputs=document.checkForm.interesting;
    //for(var i in inputs){
        for(var i=0;i<inputs.length;i++){
        inputs[i].checked=true;
    }
}
function deselectAll(){
    var inputs=document.checkForm.interesting;
    for(var i in inputs){
        inputs[i].checked=false;
    }
}
function reverseAll(){
    var inputs=document.checkForm.interesting;
    for(var i in inputs){
        inputs[i].checked=!inputs[i].checked;    
    }
}
</script>
</head>
<body>
<form name="checkForm" action="#" method="get">
兴趣爱好:<br />
<input type="checkbox" name="interesting" value="1" />足球<br />
<input type="checkbox" name="interesting" value="2" />篮球<br />
<input type="checkbox" name="interesting" value="3" />羽毛球<br />
<input type="checkbox" name="interesting" value="4" />台球<br />
<input type="checkbox" name="interesting" value="5" />乒乓球<br />
<input type="checkbox" name="interesting" value="6" />橄榄球<br />
</form>
<input type="button" value="全选" onclick="selectAll()" />
<input type="button" value="反选" onclick="reverseAll()" />
<input type="button" value="取消" onclick="deselectAll()" />

</body>
</html>

全选反选取消-js代码,布布扣,bubuko.com

全选反选取消-js代码

标签:des   style   blog   http   java   color   

原文地址:http://www.cnblogs.com/yunmengxiaohe/p/3864074.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!