zoukankan      html  css  js  c++  java
  • js 判断判断多选表单checkbox

    html代码

    <input type="checkbox" class="ace auth_id" name="ckb[]" value="{!! $item->id !!}"/>
    <input type="checkbox" class="ace auth_id" name="ckb[]" ........... />
    <input type="checkbox" class="ace auth_id" name="ckb[]" ........... />
    <input type="checkbox" class="ace auth_id" name="ckb[]" ........... />
    <input type="checkbox" class="ace auth_id" name="ckb[]" ........... />
    <button id="pass" type="submit" class="btn btn-sm btn-primary ">通过</button>
    <button id="deny" type="submit" class="btn btn-sm btn-primary ">失败</button>

    js代码

        $('#pass').on('click',function(){
            var idArray = [];
            $('.ace.auth_id').each(function(){
                if($(this).is(':checked')){  //判断已选中
                    var id = $(this).val();  //判断未选中用if( !this.checked ) { }
                    idArray.push(id);
                }
            });
            var ids = idArray.toString();
            console.log(ids);
            $.ajax({
                type: 'post',
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url: '/manage/allEnterprisePass',
                data: {ids:ids},
                dataType:'json',
                success: function(data){
                    if(data.code == 1){
                        $('[type="checkbox"]').prop('checked','');
                        location.reload();
                    }
                }
            });
        });
    
    
  • 相关阅读:
    AsyncHttpClient使用
    索引
    jdbc--取大量数据
    oracle--with as
    spring--mybatis事务总结
    Elasticsearch环境搭建
    使用idea远程调试
    redis分布式锁的实现
    知识梳理
    Zookeeper
  • 原文地址:https://www.cnblogs.com/jiangfeilong/p/11363599.html
Copyright © 2011-2022 走看看