Reputation: 53
This is the code I have used in my webpage to get items from a list and display it as radios in my webpage for input. Html code:
{% for item in l %}
<div>
<input type="radio" name="value" value={{item}} style="color: white;" />
<label style="color: white;">{{item}}</label>
</div>
{% endfor %}
Python Code:
val = request.form.get('value')
note = request.form.get('Note')
print(val)
but in the print statement I have written in python. It prints only "from" in the terminal for any radio button I chose because all of them start with from. but when used as a label it renders fully. I cant find the problem here. So can anyone help me in fixing it
Upvotes: 0
Views: 381
Reputation: 169
You're missing quotation marks around the placeholder. With your code this is what's rendered, in effect, for the first item:
<input type="radio" name="value" value="from" 0-50 style="color: white;" />
The 0-50
is ignored (doesn't have any meaning in this context). Correct code should be:
<input type="radio" name="value" value="{{item}}" style="color: white;" />
Upvotes: 1