Reputation: 2730
I want to use Jinja variables to generate n options in a drop down. Here is an example:
Session Select: <br>
{{ sessions }}
<select style="color:black">
{% for session in sessions %}
<li>{{ session }}</li>
{% endfor %}
</select> <br><br>
The value of sessions is:
['Session 1', 'Session 2', 'Session 3']
Any thoughts?
Upvotes: 0
Views: 397
Reputation: 3693
Assuming no_sessions
is your n
value... I would try something like this:
Session Select: <br>
<select style="color:black">
{% range number from 1 to no_sessions %}
<option>Session {{ number }}</option>
{% endrange %}
</select> <br><br>
Upvotes: 1
Reputation: 1761
Session Select: <br>
<select style="color:black">
{% for session in sessions %}
<option value="{{ session }}">{{ session }}</option>
{% endfor %}
</select> <br><br>
Upvotes: 0
Reputation: 599708
To generate items within a select box you use the <option>
tag, not <li>
.
Upvotes: 0