Reputation: 728
I made a simple application on Pythonanywhere using Flask framework. When I submit a form, in the console logs I see that all information is transferred. But I don't need the name of selected item in select box, I need its value (id).
<div class="form-group">
<label for="carCarcass" class="col-lg-6 control-label">Кузов</label>
<div class="col-lg-6">
<select class="form-control" id="carCarcass" name="carCarcass">
<option value="0" SELECTED>-</option>
{% for carcass in CARCASSES %}
<option value="{{ loop.index }}">{{ carcass }}</option>
{% endfor %}
</select>
</div>
</div>
When I try to get via request.form['carCarcass']
it returns the string that is between option tags.
How do I access the value?
Upvotes: 0
Views: 2865
Reputation:
actually i get this like the below method.This will print the selected values in list.
name=request.form.getlist('carCarcass')
for x in name:
print("x",x)
Upvotes: 0