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

256
Vistas
how to make multiple select checkbox with ajax and no button submit

Python 3.9 Django 3.2 I have categories and product , and through a simple form in the template I choose 1 or 2-3 checkboxes and I get the result. How to do it now via ajax and without button 'submit'.

I select several product categories and each click on the checkbox is ajax and the next click on the checkbox adds the parameter to the request.

it is similar to how you select several parameters in online stores. You have selected 2 parameters and received a filtered list of products

I suppose that you need to intercept the sending, store one request in the cache and add a new one to this request

              <form  method="post" id="category-box">
                {% csrf_token %}
                <div class="form-check">
                  <input class="form-check-input" type="checkbox" name='category' value="{{c.name}}" >
                  <label class="form-check-label" for="{{c.name}}"><a href="{{ c.get_absolute_url }}">{{ c.name }}</a></label>
                </div>
                {% endfor %}
                <button type="submit">Submit</button>
              </form>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can have an onChange on the form element which triggers when any input within the form has been changed. When the form changes, you send AJAX request with updated params and load new data.

This might be hurtful for performance though, clicking multiple checkboxes in short period of time would trigger a request for each click which is unnecessary. That can be handled with a slight delay before sending the request and a check if the form has changed subsequently.

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