zoukankan      html  css  js  c++  java
  • 多选checkbox

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script  src="jquery.min.js"></script>
    </head>
    <body>
        <form id='myForm' name="myForm" method="post" action="test6.php">
    <input type="checkbox" id='all' >:全部</input>

    <input type="checkbox" class="list" name='list[]' value="1" >:1</input>

             <input type="checkbox" class="list" name='list[]' value="2" >:2</input>
             <input type="checkbox" class="list" name='list[]' value="3" >:3</input>

            <br/>
            <br/>
            <select name="select">
                <option>1</option>
                <option>2</option>
                <option>3</option>
            </select>
            <input type="button" id="but" value="sub"></input>
            <input type="submit" id="but" value="sub12"></input>
        </form>
    </body>
    </html>
    <script type="text/javascript">
        $(document).ready(function($) {    
            $("#all").click(function(event) {
                if($('#all').prop('checked')){
                    $('.list').prop('checked',true);
                }else{
                    $('.list').prop('checked',false);
                }
            });
            $(".list").click(function(event) {
                var arr_stu = [];
                $('.list').each(function(index, el) {
                    var statu = $(this).prop('checked');
                    arr_stu.push(statu);
                });
                $.unique(arr_stu).length==1?$('#all').prop('checked',true):$('#all').prop('checked',false);
            });
    
            $('#but').click(function(){
                var data = $('#myForm').serialize();
                $.ajax({
                    url: 'test6.php',
                    type: 'post',
                    dataType: 'json',
                    data: data,
                    success:function(result){
    
                    }
                })
                
            })
        });
    </script>
  • 相关阅读:
    Linux之mysql的重新安装
    prometheus监控采集数据promSql
    安装grafana
    prometheus server主配置文件prometheus.yml
    【Java拾遗】不可不知的 Java 序列化
    Centos7 openssh 离线升级8.4
    web for pentester sqli
    web for pentester xss
    ESXI 安装脚本
    nginx 499状态码排查
  • 原文地址:https://www.cnblogs.com/kevin2016/p/7464405.html
Copyright © 2011-2022 走看看