最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

how do i create a prompt in javascript with 3 checkboxesradio buttons as choices? - Stack Overflow

programmeradmin1浏览0评论

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
  • i don't think this is possible. – Jason Commented May 16, 2011 at 23:50
  • the above comment is in reference to an actual prompt() call. Of course there are other ways to mimic this. – Jason Commented May 17, 2011 at 0:06
Add a comment  | 

3 Answers 3

Reset to default 9

You 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:

  1. jQuery UI (dialog)
  2. 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.

发布评论

评论列表(0)

  1. 暂无评论