zoukankan      html  css  js  c++  java
  • 全选反选取消-js代码

    <!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>
  • 相关阅读:
    记录JavaScript的util.js类库
    Shiro登录中遇到了问题
    【转载】JavaScript导出Excel
    react-router
    react 表单
    html5定位getLocation()
    html5存储方式localstorage和sessionStorage
    position导致Safari工具栏不自动隐藏
    input type="datetime-local" 时placeholder不显示
    vuex(1.0版本写法)
  • 原文地址:https://www.cnblogs.com/yunmengxiaohe/p/3864074.html
Copyright © 2011-2022 走看看