Ryan
Ryan

Reputation: 141

Dialog pop up box

I would like to make register button, but when people click on it. A pop up dialog will appear and has two button for user to click. One is YES , One is NO. IF they select YES, will pass them to X page. Convert way, they select NO, will pass them to Y page. I search on google but only OK and cancel confirm. enter image description here

YES --> VIP REGISTER

NO --> REGULAR REGISTER

Should i use Jquery?

Upvotes: 0

Views: 685

Answers (4)

Alnitak
Alnitak

Reputation: 340055

You can use jQuery UI for this.

$('<div>', {text: 'Do you have VIP code?'}).dialog({
    modal: true,
    buttons: {
        'Yes': function() {
             window.location = ...;
        },
        'No': function() {
             window.location = ...;
        }
    }
});

Note that this dialog box will by default include a "close" button and will also close automatically if you press escape. You need to either disable those features (see here for how), or decide what action to take (if any) when that happens.

Upvotes: 1

Jan Hommes
Jan Hommes

Reputation: 5152

jquery is a good way to do this very easy. But often the problem is, people belive they can use jQuery without understanding Javascript itself. So, first learn the basics of Javascript (for Example: Methodchaning, Closurs, Array-Handling, Prototyping) and after that try jQuery. The Box you want is very easy to do with jQuery-UI and

window.location = "vip.html";

Upvotes: 0

jazzytomato
jazzytomato

Reputation: 7239

You can do this in classic javascript

var answer = confirm ("Do you have vip code?")

and then treat the answer accordingly

Upvotes: 0

James Allardice
James Allardice

Reputation: 166061

You can use the built-in confirm method if you don't want to customise the look-and-feel of the dialog (you can't change anything, including the text of the buttons):

if (confirm("Do you have VIP code?")) {
    //Yes!
} else {
   //No
}

If you want to customise the dialog, look at the endless lightbox scripts that are available. As mentioned by @Alnitak, jQuery UI provides a good one.

Upvotes: 0

Related Questions