<?php
//$this->load->model('Kategori_admin_model');

$id_cek=uniqid();
?>
<table class="table table-bordered table-striped"> 
                                <thead>
                                    <tr>
                                        <th class="text-center">Kategori</th>
                                        <th class="text-center action">Pilih All
                                        <input type="checkbox" name="select-all" id="<?php echo $id_cek;?>" />
                                        </th>
                                    </tr>
                                </thead>
                                <tbody><?php 
    $no = 1;

    foreach($jenis_form as $jenis_form){
        $cek="";
        $id_jenis_form=$jenis_form->id_jenis_form;

        $cek_akses=$this->Kategori_admin_model->count_check($id_jenis_form, $id_user);
        if($cek_akses > 0){
            $cek="checked = true";
        }else{
            $cek="";
            
        }

?>
                                    <tr>
                                        <td><?= ' '.$jenis_form->nama_jenis_form ?></td>
                                        <td class="text-center">
                                            <input type="checkbox" class="checkss" <?php echo $cek;?> name="<?= $jenis_form->id_jenis_form ?>">
                                        </td>
                                    </tr>

<?php 
    $no++;
    }
?>
                                </tbody>
                            </table>
<script>
    $('#<?php echo $id_cek;?>').click(function(event) {   
    if(this.checked) {
        // Iterate each checkbox
        $(':checkbox').each(function() {
            this.checked = true;                        
        });
    } else {
        $(':checkbox').each(function() {
            this.checked = false;                       
        });
    }
});
</script>