Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda