title: Can I make dependent select box populated through Jinja variables?
body: <p>I'm using Flask with Jinja2 templates, how can I make dependent select pox using Jinja2 or using Java script + Jinja2 variable?</p>
  
  <p><strong>Example:</strong></p>
  
  <p><em>Python side:</em></p>
  
  <pre><code>@app.route('/')
  def dependent():
      cars= {'Chevrolet':['Volt','Malibu','Camry'],'Toyota':['Yaris','Corolla'],'KIA':['Cerato','Rio']}
      return render_template('select.html',cars=cars)
  </code></pre>
  
  <p>HTML+Jinja side</p>
  
  <pre><code>&lt;form&gt;
  &lt;select name="car_vendor" id="car_vendor"&gt;
      {% for key, value in cars.items() %}
          &lt;option value="{{ key }}"&gt; {{ key }} &lt;/option&gt;
      {% endfor %}
  &lt;/select&gt;
  
  
  &lt;select name="car_model" id="car_model"&gt;
      ---
      ---
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>How can I populate car_model select box dependently on the car_vendor select box</strong> like in the picture:</p>
  
  <p>PS: I'm completely ignorant regarding JS, jQuery and Ajax, I've seen many JS or jQuery examples and I was like a man lost and paralyzed in the desert, So please if you're going to help, edit my code example and don't link me to external links. Thanks in advance.</p>
  
  <p><a href="https://i.stack.imgur.com/f8YFw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f8YFw.png" alt="enter image description here"></a></p>