我有2个单选按钮,但可以选择两个单选按钮,
<form class="descriptions" id="collection" method="post" action="">
<table width="200">
<tr>
<td>
<label>Collection</label>
<input type="radio" value="collection" />
</td>
<td>
<label>Delivery</label>
<input type="radio" value="delivery" />
</td>
</tr>
</table>
</form>
我知道这很容易,但我似乎无法找到答案, 任何帮助将不胜感激。
答案 0 :(得分:23)
给他们相同的名字。
答案 1 :(得分:5)
Description of the radio button control type in the HTML 4.01 specification:
单选按钮就像复选框一样,只有当多个按钮共享相同的control name时,它们是相互排斥的:当一个按钮被“打开”时,所有其他具有相同名称的按钮都会被“关闭”。
答案 2 :(得分:1)
<form class="descriptions" id="collection" method="post" action="">
<table width="200">
<tr>
<td>
<label>Collection</label>
<input type="radio" name="samename" value="collection" />
</td>
<td>
<label>Delivery</label>
<input type="radio" name="samename" value="delivery" />
</td>
</tr>
</table>
</form>
//这是您遇到以下问题的正确答案//