mardi 22 novembre 2016

all checked when first checkbox checked

i have a problem with checkbox . i want to check all when the first checkbox is checked. this is my code

<tr>
                    <td><label for="">Pilih Pendidikan</label></td>
                    <td style="text-align:left;">
                        <input type="checkbox" id="pilih_semua_pdk">Pilih Semua
                        <?php foreach ($query2 as $row2) {?>
                          <input class="form-control required check_pdk" type="checkbox" name="pendidikan[]" value="<?php echo $row2[id_pendidikan]; ?>"
                              <?php
                                $pendidikan = $_POST[pendidikan];
                                  if ($pendidikan !=NULL) {
                                      foreach($pendidikan as $pendidikan){
                                        if ($pendidikan == $row2[id_pendidikan]) {
                                          echo "checked";
                                        }
                                    }

                                  }
                              ?>
                          ><?php echo $row2[nama_pendidikan]; ?>
                        <?php  } ?>
                      </td>
                    </tr>

i try this code but doesnt work

<script>
$("#ckbCheckAll").click(function () {
    $(".checkBoxClass").prop('checked', $(this).prop('checked'));
</script>




Aucun commentaire:

Enregistrer un commentaire