Javascript 中的无线电输入和警报
我需要一些帮助。 我有一个程序可以根据单选框中的用户输入更改表值 类似于此页面:
但问题是我希望用户选择无线电输入仅一次;如果他们选择另一个 那么表的值就会变得混乱。 所以我想知道的是,当用户选择无线电输入两次时如何制作警报框?
与此网站类似clicky尝试单击单选按钮两次并弹出警报。
请问有人可以帮忙吗?
I need some help.
I have program that changes table values based on user input in radio box
similar to this page:
But the problem is I want users to select the radio input only once; if they select another
radio then values of tables get messed up.
So what I want to know is how can I make an alert box when user selects the radio input twice?
Similar to this website clicky try clicking radio button twice and alert popsup.
Please can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果不引入外部库的帮助,很难阻止单选按钮输入节点上的事件。一个简单的解决方案是仅禁用附加到每个输入节点的 onclick 函数中的按钮。像这样: http://jsfiddle.net/c73Mh/ 。如果他们出于某种原因仍然需要能够选择单选按钮,您可以通过选择最初从同一功能中选择的按钮来取消选择。希望这有帮助!
It's difficult to prevent an event on a radio button input node without bringing in help from outside libraries. A simple solution is to just disable the buttons from within an onclick function attached to each input node. Like so: http://jsfiddle.net/c73Mh/ . If they still need to be able to select the radio buttons for whatever reason, you can cancel the selection by selecting the button that was initially selected from within that same function. Hope this helps!
为了简单起见,在我的示例中,我假设每个单选按钮的 id 是名称和值属性的组合。除了我在下面给您提供的内容之外,您还需要添加某种类型的 Reset() 函数来设置
selectedValues = {};
并取消选择所有单选按钮。For simplicity in my example I'm assuming that the id of each radio button is a combination of the name and value attributes. In addition to what I've given you below you will need to add a reset() function of some kind that sets
selectedValues = {};
and deselects all radio buttons.