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

130
Views
Adding Plus minus button in form with POST and scrf_tocken

With Django I generate a list of items, with the number of them. To be more convenient, I would like to add a plus and a minus button.

I found a simple solution, but when I try to put this in my form with the POST method, if click the page refresh or POST ?

I don't want to refresh the page every time, I have a validate button and all the value will be treat in one time.

 <form class"form-inline" action="{% url 'stock:stock' %}"method="post" >{% csrf_token %}
   {% for stock in stocks %}
     <div>
      <button id="minusButton">-</button>
      <input type="number" name="stock" id="stock" value="{{stock.stock}}" >
      <button id="plusButton">+</button>
     </div>
   {% endfor %}
</form>

<script>
  textInput = document.querySelector('#numberInput');
  plusButton = document.querySelector('#plusButton');
  minusButton = document.querySelector('#minusButton');
  plusButton.onclick = () => textInput.value = parseInt(textInput.value) + 1;
  minusButton.onclick = () => textInput.value = parseInt(textInput.value) - 1;  
</script>

If anyone know how to manage?

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