title: Set default value for select html element in Jinja template?
body: <p>I'm using flask/jinja in order to make a simple web application. I have a table of records which is taken from a db table, and is called by a webpage which loads the list of records. On each row there is a dropdown list (done using the select HTML tag) on a column. </p>
  
  <p>I realize the below code doesn't do what its supposed to, currently the last option (fourth) is automatically selected because of the selected tag. I've left it in to try show what I'm trying to implement.</p>
  
  <p>Ideally I'd want it to check the current record's status (rec.status in the code below) and depending on that, select the appropriate item in the dropdown.</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>     &lt;tbody&gt;
              {% for rec in records %}
          &lt;tr&gt;
            &lt;td&gt;{{ rec.task }}&lt;/td&gt;
            &lt;td&gt;
              &lt;select&gt;
                &lt;option value ="zero" selected={{rec.status==0}}&gt;Zero&lt;/option&gt;
                &lt;option value ="first" selected={{rec.status==1}}&gt;First&lt;/option&gt;
                &lt;option value ="second" selected={{rec.status==2}}&gt;Second&lt;/option&gt;
                &lt;option value ="third" selected={{rec.status==3}}&gt;Third&lt;/option&gt;
              &lt;/select&gt;
            &lt;/td&gt;
            &lt;td&gt;&lt;a href={{ "/update_status/"~rec.id}}&gt;Update&lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
        {% endfor %}
        &lt;/tbody&gt;
  </code></pre>
  
  <p>Thanks!</p>