无法选择HTML中的单选按钮? [英] Can't select between radio buttons in HTML?
本文介绍了无法选择HTML中的单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下表单代码,但无法在IE
中选择销售电台,我可以在Google Chrome中同时选择两种收音机。
I have the following form code but I cannot select the sell radio in IE and I can select both radios at once in Google Chrome.
<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>
有没有我缺少的东西...?
Is there any thing I am missing...?
推荐答案
您的单选按钮没有 name
属性。他们需要他们的原因有两个。
Your radio buttons don't have name
attribute. They need them for two reasons.
- 具有相同的名称将一组单选按钮分组到单个广播组中。 $ b
- 该名称用于生成要提交给服务器的表单数据。
- Having the same name groups a set of radio buttons into a single radio group
- The name is used to generate the form data to be submitted to the server
您还需要一个 value
来表示提交的数据将会是什么。
You also need a value
to say what the submitted data is going to be.
另外,您的<标签>
s是无用的,因为它们不与任何控件关联。他们需要一个作为
属性,它们与它们要关联的控件的 id
具有相同的值。
As an aside, your <label>
s are useless as they aren't associated with any controls. They need a for
attribute with the same value as the id
of the control they are to be associated with.
<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中的单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文