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

130
Vistas
Multiple checkbox selection at AJAX when button clicked
    <script>
        function display() {
            $.ajax({
                url: "tmp.php",
                type: "get",
                data: {
                    a: $('#selecttmp option:selected').val()
                }
            }).done(function(data) {
                $('#result').text(data);
                alert(data);

                $(document).ready(function() {
                  $('.#buttontmp').click(function() {
                    $('.data').prop('checked', this.checked);
                  });
                });
              });
            }
    </script>

enter image description here

When button is clicked, it reads the select option value and check up every relevant checkbox based on their name.

Using AJAX, select option value could be found without any refresh but checkboxes aren't checked. Am I using jquery wrongly?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

     <script>
        function display() {
            $.ajax({
                url: "test.php",
                type: "get",
                data: {
                    a: $('#selectest option:selected').val()
                }
            }).done(function(data) {
                $('#result').text(data);
                alert(data);

                $('input:checkbox[name='+data+']').each(function() {
                  this.checked = true;
                });
              });
            }
    </script>

I have figure out the solution myself, thanks for the correction that made by @CBroe.

about 4 years ago · Juan Pablo Isaza Denunciar
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