Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么我的复选框没有';不行?I';我与codeigniter合作,以下是我的观点_Php_Codeigniter_Checkbox_View - Fatal编程技术网

Php 为什么我的复选框没有';不行?I';我与codeigniter合作,以下是我的观点

Php 为什么我的复选框没有';不行?I';我与codeigniter合作,以下是我的观点,php,codeigniter,checkbox,view,Php,Codeigniter,Checkbox,View,我要选中所有子复选框的复选框 我的复选框: <table width="30%" class="table striped hovered cell-hovered border bordered"> <tr valign="middle"> <td><b>IDPEL</b></td> <td><b>No. Bar

我要选中所有子复选框的复选框

我的复选框:

<table width="30%" class="table striped hovered cell-hovered border bordered">
            <tr valign="middle">
                <td><b>IDPEL</b></td>
                <td><b>No. Baris</b></td>
                <td><b><input type="checkbox" id="pilihsemua"/> Pilih Semua</b></td>

            </tr>
            <?php

                foreach ($panel_error as $key) {



                    echo"<tr><td>".$key->errpanel."</td>";
                    echo"<td>".$key->nomorBaris."</td>";
                    echo"<td>";
                    echo form_checkbox('chk_boxes1[]',$key->errpanel);
                    echo"</td></tr>";

                }


            ?>
        </table>

IDPEL
不,巴里斯
皮利塞缪
这是我的剧本:

<script type="text/javascript">
    $(document).ready(function () {
        $('.chk_boxes').click(function(){
            $('.chk_boxes1').attr('checked',checked)
        })

        $('#table1').dataTable();
        $('#table2').dataTable();

        //checkbox
        $("#pilihsemua").click(function () { // If #pilihsemua checked, all checkbox will be checked.
            $('.chk_boxes1[]').attr('checked', checked);
        });
        // if all sub checkboxes are being checked, #pilihsemua will automatically checked.
        $(".chk_boxes1[]").click(function(){

            if($(".chk_boxes1[]").length == $(".chk_boxes1[]:checked").length) {
                $("#pilihsemua").attr("checked", "checked");
            } else {
                $("#pilihsemua").removeAttr("checked");
            }

        });
        //end of checkbox
    });

</script>

$(文档).ready(函数(){
$('.chk_框')。单击(函数(){
$('.chk_boxes1').attr('checked',checked)
})
$('#表1')。数据表();
$('#表2')。数据表();
//复选框
$(“#pilihsemua”)。单击(函数(){//如果选中#pilihsemua,则将选中所有复选框。
$('.chk_boxes1[]').attr('checked',checked);
});
//如果选中了所有子复选框,#pilihsemua将自动选中。
$(“.chk_boxes1[]”)。单击(函数(){
如果($(“.chk_-boxes1[]”)。长度==$(“.chk_-boxes1[]:选中”)。长度){
美元(“#pilihsemua”).attr(“已检查”、“已检查”);
}否则{
$(“#pilihsemua”)。移除(“选中”);
}
});
//结束复选框
});

但是,我仍然不知道为什么,这不可能是工作。我试图检查#pilihsemua,但没有检查所有子类。或者,如果我检查了所有的子类,那么“pilihsemua”也不会被检查。

可能与此相近:

但是这个脚本有一些缺陷。。试着找出什么地方出了问题

例如: HTML代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<table width="30%" cellspacing="1" cellpadding="1" border="collapse">
            <tr>
                <td><b><input type="checkbox" class="group" chk="g1"/> Pilih Semua</b></td>
                <td><b><input type="checkbox" class="group" chk="g2"/> Pilih Semua</b></td>
                <td><b><input type="checkbox" class="group" chk="g3"/> Pilih Semua</b></td>
            </tr>
            <tr>
              <td>
                <input type="checkbox" class="g1"/>
                <input type="checkbox" class="g1"/>
                <input type="checkbox" class="g1"/>
              </td>
              <td>
                <input type="checkbox" class="g2"/>
                <input type="checkbox" class="g2"/>
                <input type="checkbox" class="g2"/>
              </td>  
              <td>
                <input type="checkbox" class="g3"/>
                <input type="checkbox" class="g3"/>
                <input type="checkbox" class="g3"/>
              </td>  
            </tr>

        </table>

也许它接近于此:

但是这个脚本有一些缺陷。。试着找出什么地方出了问题

例如: HTML代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<table width="30%" cellspacing="1" cellpadding="1" border="collapse">
            <tr>
                <td><b><input type="checkbox" class="group" chk="g1"/> Pilih Semua</b></td>
                <td><b><input type="checkbox" class="group" chk="g2"/> Pilih Semua</b></td>
                <td><b><input type="checkbox" class="group" chk="g3"/> Pilih Semua</b></td>
            </tr>
            <tr>
              <td>
                <input type="checkbox" class="g1"/>
                <input type="checkbox" class="g1"/>
                <input type="checkbox" class="g1"/>
              </td>
              <td>
                <input type="checkbox" class="g2"/>
                <input type="checkbox" class="g2"/>
                <input type="checkbox" class="g2"/>
              </td>  
              <td>
                <input type="checkbox" class="g3"/>
                <input type="checkbox" class="g3"/>
                <input type="checkbox" class="g3"/>
              </td>  
            </tr>

        </table>

类名不随
[]
一起提供。您正在jquery中使用name。请检查并链接,这真的很有帮助!非常感谢你!类名不随
[]
一起提供。您正在jquery中使用name。请检查并链接,这真的很有帮助!非常感谢你!