HTML单选按钮允许多个选择 [英] HTML radio buttons allowing multiple selections
本文介绍了HTML单选按钮允许多个选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的HTML表单中,我有下面的一组单选按钮,具体取决于你选择的单选按钮取决于下一个表单< fieldset>
是否显示,这一切都有效。问题出于某种原因,它们像复选框一样工作,而不是单选按钮。所以你可以选择所有的选项,而不是一次只选择一个。
In my HTML form I have the below as a set of radio buttons, depending on what radio button you select depends on what the next form <fieldset>
is revealed, this all works. The problem is for some reason they are working like a check box and not as a radio button. So you can select all options and not just the one at a time.
任何人都可以在下面的代码中看到错误的地方吗?
Can anyone see where this is going wrong in the code below?
<fieldset>
<legend>Please select one of the following</legend>
<input type="radio" name="track" id="track" value="track" /><label for="track">Track Submission</label><br />
<input type="radio" name="event" id="event" value="event" /><label for="event">Events and Artist booking</label><br />
<input type="radio" name="message" id="message" value="message" /><label for="message">Message us</label><br />
</fieldset>
推荐答案
他们都需要相同 name
属性。
单选按钮按名称分组
属性。以下是一个例子:
The radio buttons are grouped by the name
attribute. Here's an example:
<fieldset>
<legend>Please select one of the following</legend>
<input type="radio" name="action" id="track" value="track" /><label for="track">Track Submission</label><br />
<input type="radio" name="action" id="event" value="event" /><label for="event">Events and Artist booking</label><br />
<input type="radio" name="action" id="message" value="message" /><label for="message">Message us</label><br />
</fieldset>
这篇关于HTML单选按钮允许多个选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文