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

215
Views
How to update the options (django queryset variable) of select tag based on the value of onchange event in django template?

I will need to update the option values after a selection in Django template?

For example,

<select id="state" type="text" name="state" onChange="update()">
   <option value="">Select state</option>
   {% for state in state %}
   <option value="{{state.id}}"
       {{state.name|capfirst}}
   </option>
   {% endfor %}
</select>

After selection of the state I want to update the city queryset according to the selected state. For example, if anyone select California as their state, I want to just give the options of the cities that are inside California state.

<select id="city" type="text" name="city">
   <option value="">Select city</option>
   {% for city in city %}
   <option value="{{city.id}}"
       {{city.name|capfirst}}
   </option>
   {% endfor %}
</select>

Can anyone suggest what would be the best way to approach this?

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!