Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda