admin管理员组文章数量:1221312
How do I create a javascript prompt box where you have to select 1 of 3 choices? I'm looking to do something similar to a html form's radio buttons except within a javascript prompt.
How do I create a javascript prompt box where you have to select 1 of 3 choices? I'm looking to do something similar to a html form's radio buttons except within a javascript prompt.
Share Improve this question asked May 16, 2011 at 23:49 IncognitoIncognito 1,9535 gold badges21 silver badges28 bronze badges 2 |3 Answers
Reset to default 9You could use jQuery and do a 3 button dialog(). Check out this working jsFiddle demo:
$("#dialog").dialog({
autoOpen: true,
buttons: {
Yes: function() {
alert("Yes!");
$(this).dialog("close");
},
No: function() {
alert("No!");
$(this).dialog("close");
},
Maybe: function() {
alert("Maybe!");
$(this).dialog("close");
}
},
width: "400px"
});
This can't be achieved natively as .prompt()
. This functionality requires more advanced JS. Here are some libs to mess with:
- jQuery UI (dialog)
- jQuery Tools - Overlay
Could be more adequate ones out there. Been a while using such stuff
You can't do this from an "alert" box if thats what you mean.. But you could use any number of libraries to create a popup window which is basically just a and do your form within there.
You could then tie a button or whatever to a function which closes the box and parses the form into your structures within Javascript.
本文标签: how do i create a prompt in javascript with 3 checkboxesradio buttons as choicesStack Overflow
版权声明:本文标题:how do i create a prompt in javascript with 3 checkboxesradio buttons as choices? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739332246a2158536.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
prompt()
call. Of course there are other ways to mimic this. – Jason Commented May 17, 2011 at 0:06