Reputation: 2901
I need to ask my web site's user a Yes/ No question. Currently I use JavaScript's confirm() function. The return value is true (OK) or false (CANCEL). The word CANCEL is misleading. I want to have the buttons say Yes/ No instead. How can I do it? i m using php..Code should run on both IE & Firefox
Upvotes: 2
Views: 1381
Reputation: 3542
Use something like jQuery UI. It has a nice dialog (including modal). As well as it have many other nice feature you may need in your webapp.
Of course you can paraphrase your question for OK/Cancel answer. But i think UI library is your friend.
Upvotes: 1
Reputation: 24098
With HTML:
<div id="yesNo">
<p>Press Yes or No</p>
</div>
and jQuery:
$('#yesNo').dialog({
modal: true,
buttons: {
"Yes": function() { alert("Yes"); }
"No": function() { alert("No"); }
}
});
Or use standard confirm dialog (but it will have Ok, Cancel buttons):
if (confirm("Are you sure?")) {
alert("Yes");
} else {
alert("No");
}
Upvotes: 4
Reputation: 8928
If you truly cannot rephrase the question as OK/Cancel, then you will need to create your own dialog in a div or something and 'pop it up' to the user. (You could also create a dialog as a page and then use a popup window to display it as a real native OS modal dialog, but this is perhaps more annoying.)
Unfortunately, javascript's browser built in dialogs are pretty limited.
Upvotes: 1