如何只允许选中一个单选按钮? [英] How to allow only one radio button to be checked?
本文介绍了如何只允许选中一个单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
{% for each in AnswerQuery %}
<form action={{address}}>
<span>{{each.answer}}</span><input type='radio'>
<span>Votes:{{each.answercount}}</span>
<br>
</form>
{% endfor %}
这是我的django模板的一部分,它应该做的是打印出几个单选按钮,对应于分配给按钮的答案.但我不知道为什么我可以检查多个单选按钮,这让我很困惑.它应该只让我检查一个单选按钮,我以某种方式拥有它,但我失去了它.有什么帮助吗?谢谢你.
This is a part my django template, what it supposed to do is to print out several radio buttons, corresponding to the answers assigned to the buttons. But I don't know why 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.
推荐答案
只需给它们相同的名称:
Simply give them the same name:
<input type="radio" name="radAnswer" />
这篇关于如何只允许选中一个单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文