when user clicks check all first, second checkbox should be unchecked and vice versa, for now everything is checked.
What I'm trying to do is get something to select all checkboxes. But what works is currently selected not all by id, I want to do it based on $item->payroll_group_id
my code in index.blade.php
@foreach ($unit as $item)
@if ($item->payroll_group_id == null || $item->payroll_group_id == $payroll_id)
<tr class='employee-row'>
<td><input type="checkbox" class="emp-check" id="check" name="employee_id[]" value="">
<input type="hidden" class="py-sid" value=""></td>
<td class='captial'></td>
<td class='captial'></td>
</tr>
@endif
@endforeach
Here is the javascript for this
<script>
function toggle(source) {
var checkboxes = document.querySelectorAll('input[id="check"]');
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i] != source)
checkboxes[i].checked = source.checked;
}
}
</script
how to solve my problem please help me.
Aucun commentaire:
Enregistrer un commentaire