My problem is that I'm not getting any value back from my select form. I pass a list of stocks to the jinja template via return render_template("sell.html", stocks=stocks)
and on the sell.html
page I have the select form set up as
{% block main %}
<form action="/sell" method="post">
<div class="form-group">
<select class="form-control" name="symbol" form="sell">
{% for stock in stocks %}
<option value="{{ stock.symbol }}">{{ stock.symbol }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<input class="form-control" name="shares" placeholder="Amount" type="number"/>
</div>
<button class="btn btn-primary" type="submit">Sell</button>
</form>
{% endblock %}
This works so far as it shows the stocks correctly on the drop-down menu, but when I try to get the selected value back via symbol = request.form.get("symbol")
the returned value is None. (tested by passing the symbol back into the template and just printing it out, it showed None for all selected options).
id="sell"
to yourform
element? I have never seen thisform="sell"
before (haven't done that much HTML5), it might be the reason.form="sell"
parameter when I was already working in anotherform
tag. Removing it fixed the problem.