I made 3 input checkbox with input name, id, dt, ts. where dt and ts are disabled so when i click id then input dt and ts will be enabled, but i have problem can not access array.
<table id="tbl_employee" class="table table-striped table-bordered show-child-rows" style="width:100%">
<thead>
<tr>
<th class="text-center" width="5%">ID</th>
<th class="text-center" width="5%">DT</th>
<th class="text-center" width="5%">TS</th>
</tr>
</thead>
<tbody>
<?php foreach ($employee as $row){?>
<tr>
<td class="text-center" width="5%"><input type="checkbox" name="id[<?= $row['id_p']?>]" value="<?= $row['id_p']?>"></td>
<td class="text-center" width="5%"><input type="checkbox" name="dt[<?= $row['id_p']?>]" value="1" disabled></td>
<td class="text-center" width="5%"><input type="checkbox" name="ts[<?= $row['id_p']?>]" value="1" disabled></td>
</tr>
<?php } ?>
</tbody>
</table>
$(document).ready(function() {
$('[name="id[<?= $row['id_p']?>]"]').click(function() {
var checked = $(this).is(':checked');
if (checked) {
$('[name="dt[<?= $row['id_p']?>]"]').prop('disabled', false);
$('[name="ts[<?= $row['id_p']?>]"]').prop('disabled', false);
} else {
$('[name="dt[<?= $row['id_p']?>]"]').prop('disabled', true);
$('[name="ts[<?= $row['id_p']?>]"]').prop('disabled', true);
}
});
})
Aucun commentaire:
Enregistrer un commentaire