Clinteney Hui Clinteney Hui - 3 months ago 8
HTML Question

how to set that only one radio button can be checked

{% for each in AnswerQuery %}
<form action={{address}}>
<span>{{each.answer}}</span><input type='radio'>
<span>Votes:{{each.answercount}}</span>
<br>
</form>
{% endfor %}


this is a part my django template, what it supposed to do is to print out several radio button corresponding to the answers assigned to the buttons. But I dont know why that I can check multiple radio buttons, which messed me up. It is supposed to only let me check on one radio button and I had that somehow but I lost it. Any help? Thank you

Answer

Simply give them the same name:

<input type="radio" name="radAnswer" />
Comments