title: Chained Dropdown in flask, get data from sqlite database
body: <p>I am trying to get a html select tag with different counties (getting from database), when the user have selected a county, I want another select tag to enable and show the cities in that county (I have the data in a sqlite database, where the county id is in the city database). I am using python in Pycharm, with flask and I haven't found any good tutorials. </p>
  
  <p>Is there an easy way of using some extension to flask? I saw something about sijax, but I never understood how to use it.</p>
  
  <p>The code I have is something like this, but I guess the city-part has to be created through some javascript thingy:</p>
  
  <pre><code>        &lt;div class="form-group"&gt;
              &lt;label for="inputCounty"&gt;County&lt;/label&gt;
              &lt;select class="form-control" id="select_county" name="select_county"&gt;
                  &lt;option value=""&gt;Choose county&lt;/option&gt;
                  {% for county in counties %}
                      &lt;option value="{{ county.id }}"&gt;{{ county.name }}&lt;/option&gt;
                  {% endfor %}
              &lt;/select&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;label for="inputCity"&gt;City&lt;/label&gt;
              &lt;select class="form-control" id="select_city" name="select_city"&gt;
                  &lt;option value=""&gt;Choose city&lt;/option&gt;
                  {% for city in cities %}
                      &lt;option value="{{ city.id }}" class="{{ city.county }}"&gt;{{ city.name }}&lt;/option&gt;
                  {% endfor %}
              &lt;/select&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>I tried a "chained"-javascipt plugin but it didn't work, but that's why I have class in the option tags.</p>
  
  <p>Right now the counties and all cities are sent to the html template, but I don't think that will be sustainable later on because I want to add another dropdown with places in the cities as well, so then I have to send a lot of data that never will be used.</p>