在javascript中使复选框可点击一次?
抱歉,我对 javascript 绝对是菜鸟。
我已经制作了一个简单测验的表格,但不知道如何使收音机只点击一次。
我可以选择两个或三个按钮作为我的答案。我想改变这一点。
<form name = "Beginners Quiz">
<p>Film speed refers to:</p>
<p><input type="radio" name="Answer 1" id="Answer1" value = "a" onclick = "recordAnswer(1,this.value"/>How long it takes to develop film. <br/>
<p><input type="radio" name="Answer 2" id="Answer2" value = "b" onclick = "recordAnswer(1,this.value"/>How fast film moves through film-transport system. <br/>
<p><input type="radio" name="Answer 3" id="Answer3" value = "c" onclick = "recordAnswer(1,this.value"/> How sensitive the film is to light. <br/>
<p><input type="radio" name="Answer 4" id="Answer4" value = "d" onclick = "recordAnswer(1,this.value"/> None of these makes sense. <br/>
我一直在寻找 w3shcools 教程,但没有成功。有人可以透露一些信息吗?
Sorry but im an absolute noob with javascript.
Ive made a form for a simple quiz but cant figure out how to make radio's only click once.
I can select two or three buttons as my answer. i want to change this.
<form name = "Beginners Quiz">
<p>Film speed refers to:</p>
<p><input type="radio" name="Answer 1" id="Answer1" value = "a" onclick = "recordAnswer(1,this.value"/>How long it takes to develop film. <br/>
<p><input type="radio" name="Answer 2" id="Answer2" value = "b" onclick = "recordAnswer(1,this.value"/>How fast film moves through film-transport system. <br/>
<p><input type="radio" name="Answer 3" id="Answer3" value = "c" onclick = "recordAnswer(1,this.value"/> How sensitive the film is to light. <br/>
<p><input type="radio" name="Answer 4" id="Answer4" value = "d" onclick = "recordAnswer(1,this.value"/> None of these makes sense. <br/>
ive been rooting around w3shcools tutorials to no avail. can someone shed some light?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它们应该都具有相同的
name
属性They should all have the same
name
attribute您想要作为一个组的所有单选按钮的名称必须相同。
The name needs to be the same for all the radio buttons you want to act as a group.
试试这个
Try this
这是一个方法...
编辑不需要Javascript,自从我使用收音机以来已经有一段时间了。
在身体里,你有这个:
这应该可以。
Here's an approach...
EDIT No Javascript needed, been awhile since I worked with radios.
In the body, you have this:
This should do it.