Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
How to Select All Checkboxes By ID

when user clicks check all first, second checkbox should be unchecked and vice versa, for now everything is checked. enter image description here

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="{{ $item->employee_id }}">
                                    <input type="hidden" class="py-sid" value="{{ $item->payroll_group_id }}"></td>
                                    <td class='captial'>{{ $item->name }}</td>
                                    <td class='captial'>{{ $item->position ?? '-' }}</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.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!