我有以下表单代码,但我无法在 IE 中选择出售电台 我可以在 Google Chrome 中同时选择两个 radio 。
<form method="post" action="dothemath.php" style="width: 403px" class="style1">
<input type="radio" id="rdobuy" style="width: 20px; height: 21px;" checked="checked"/>
<label>Buy</label>
<input type="radio" id="rdosell" style="width: 20px; height: 21px;"/>
<label >Sell</label>
</form>
有什么我想念的吗...?
最佳答案
您的单选按钮没有 name
属性。他们需要它们有两个原因。
- 使用相同的名称将一组单选按钮组合成一个单选组
- 名称用于生成提交给服务器的表单数据
您还需要一个 value
说明提交的数据是什么。
顺便说一句,你的 <label>
s 是无用的,因为它们不与任何控件相关联。他们需要一个 for
与 id
具有相同值的属性他们要关联的控件。
<form method="post" action="dothemath.php">
<input type="radio" id="rdobuy" name="foo" value="buy" checked="checked"/>
<label for="rdobuy">Buy</label>
<input type="radio" name="foo" value="sell" id="rdosell" />
<label for="rdosell">Sell</label>
</form>
关于html - 无法在 HTML 中的单选按钮之间进行选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8288350/