Probably a stupid question, but I can’t work out how to retrieve the values of anything other than input fields using python with Flask. For example, I have an html form with a element:
<form action="/newgame" method="POST">
<input type="text" name="white">
<select>
<option name="result" value="onezero">1-0</option>
<option name="result" value="zeroone">0-1</option>
<option name="result" value="draw">draw</option>
</select>
<input type="text" name="black">
<input type="submit" value="submit">
</form>
On serverside, if I call print request.form.items(True), then I can retrieve the values from the two <input type="text"> elements, but not from the <select> element.
I had a similar issue where I wanted to have a form with two submit buttons and then work out on the serverside which button had been used to submit the form. I had no luck with this either.
Help and advice appreciated.
Your
nameattribute needs to be on theselectelement, not theoptionelements. Like so: