谁能告诉我如何将组名应用到html (输入)单选按钮控件中,以便我可以选择任何一个可用的单选按钮?
我有一张桌子上的输入收音机。每行包含两个无线电,如下所示。我想从每一行中选择一个。但我只能在所有行上的所有单选按钮中选择一个单选按钮。
<input name="radiobutton" type="radio" value="radiobutton" />Option1
<input name="radiobutton" type="radio" value="radiobutton" />Option2要在每一行上选择一个单选按钮,我必须进行什么更改?
谢谢,~卡普斯
发布于 2010-01-19 14:50:24
据我所知,HTML中的单选按钮没有组名。它们的HTML " name“属性是组名。
验证每个单选按钮是否具有唯一的"value“属性是很重要的。否则,将无法判断选择了哪个重复值:
<input name="radiobutton" type="radio" value="radiobutton1" />Option1
<input name="radiobutton" type="radio" value="radiobutton2" />Option2 发布于 2010-01-19 14:56:38
此示例允许您在每个表行中仅选择一个单选按钮。您必须为所有单选按钮提供相同的Name=,才能创建一组互斥的单选按钮。
<form>
<table>
<tr><td>
<!-- Can choose only one of these two. -->
<input name="group1" type="radio" value="1a" />Option1
<input name="group1" type="radio" value="1b" />Option2
</td></tr>
<tr><td>
<!-- Can choose only one of these two. -->
<input name="group2" type="radio" value="2a" />Option1
<input name="group2" type="radio" value="2b" />Option2
</td></tr>
</table>
</form>发布于 2019-11-30 00:43:10
asp.net中的GroupName to HTML单选按钮
https://www.javatpoint.com/asp-net-radiobutton
<form id="form1" runat="server">
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Gender"></asp:Label>
</td>
<td>
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="gender" Text="Male" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="gender" Text="Female" />
</td>
</tr>
</table>
</form>
从asp.net控件标记呈现为html后
<form method="post" action="./WebControlsASPX.aspx" id="form1">
<table>
<tr>
<td>
<span id="Label1">Gender</span>
</td>
<td>
<input id="RadioButton1" type="radio" name="gender" value="RadioButton1" /><label for="RadioButton1">Male</label>
<input id="RadioButton2" type="radio" name="gender" value="RadioButton2" /><label for="RadioButton2">Female</label>
</td>
</tr>
</table>
</form>
https://stackoverflow.com/questions/2091574
复制相似问题