我有一系列单选按钮,其中我只想1能够被选中。我把它们都用同一个名字,所以我认为这样做会有所作为,但我仍然可以选择所有四个。
<h1>Portion</h1>
<input type="radio" name="portion_num" value="2" /> Two
<input type="radio" name"portion_num" value="4" /> Four
<input type="radio" name"portion_num" value="6" /> Six
<input type="radio" name"portion_num" value="8" /> Eight
答案 0 :(得分:5)
答案 1 :(得分:1)
将它们放在表格标签内。
喜欢这样
<form>
<input type="radio" name="portion_num" value="2" /> Two
<input type="radio" name="portion_num" value="4" /> Four
<input type="radio" name="portion_num" value="6" /> Six
<input type="radio" name="portion_num" value="8" /> Eight
</form>
答案 2 :(得分:0)
<form>
<input type="radio" name="portion_num" value="2" />Two
<input type="radio" name="portion_num" value="4" />Four
<input type="radio" name="portion_num" value="6" />Six
<input type="radio" name="portion_num" value="8" />Eight
</form>