如何确定接受哪个单选按钮?
如何确定接受哪个单选按钮?
当我使用单选按钮时,如何防止用户选择多个选项?
<input type='radio' name='one'>option1<br />
<input type='radio' name='two'>option2<br />
<input type='radio' name='three'>option3<br />
<input type='radio' name='four'>option4<br />
<input type='radio' name='five'>option5<br />
这就是我使用的代码,感谢您的阅读。
How can I identify which radio button is accepted?
How do I prevent a user being able to select multiple options when I use radio buttons?
<input type='radio' name='one'>option1<br />
<input type='radio' name='two'>option2<br />
<input type='radio' name='three'>option3<br />
<input type='radio' name='four'>option4<br />
<input type='radio' name='five'>option5<br />
Thats the code I use, thanks for reading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要使用“name”属性将它们连接在一起,使用 value 属性为它们提供不同的值。
将名字视为姓氏...例如,如果您有 Bart、Lisa、Homer、Marge 和 Maggie,则名称将是他们的姓氏:Simpson,值将是上述名称:
You need to use the "name" attribute to tie them all together, use the value attribute to give them different values.
Think of name as last name... For example, if you had Bart, Lisa, Homer, Marge and Maggie, the name would be their last name: Simpson, the value would be the said names:
你应该给他们起同样的名字
you should give them the same name
我猜名称/值对的顺序也很重要。名称应该出现在顺序之前
Also the order of name/value pair matter's I guess.Name should appear before the order
我知道!这样做:
为“名称”属性赋予所有相同的值。您添加单选按钮的名称
I know! Do like this:
Give everything same value for 'name' attribute. You add the name for the radio buttons