无法一次选择一个单选按钮
问题描述:
我无法一次选择一个单选按钮。多个按钮正在被选中。我是新手到HTML。这是我的代码。
I am unable to select one radio button at a time. Multiple buttons are getting selected. I am newbie to html. This is my code. Please help.
<form name="ans_a" onsubmit="return answer_a()">
<table align="center" border="1">
<br>
<br>
<tr>
<td width="500px"> ABC
<br>
<input type="radio" name="A" value="a" id="radio1"> A   Option A <br>
<input type="radio" name="B" value="b" id="radio2"> B   Option B <br>
<input type="radio" name="C" value="c" id="radio3"> C   Option C <br>
<input type="radio" name="D" value="d" id="radio4"> D   Option D <br>
<br>
                 
<input type="button" name="ans1" value="Next" onclick="answer_a()">
</td>
</tr>
</table>
</form>
答
按钮时,您必须为每个 radio
按钮设置相同的名称
。
<input type="radio" name="A" value="a" id="radio1"> A   Option A <br>
<input type="radio" name="A" value="b" id="radio2"> B   Option B <br>
<input type="radio" name="A" value="c" id="radio3"> C   Option C <br>
<input type="radio" name="A" value="d" id="radio4"> D   Option D <br>