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
A:
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.
Coxy
2009-11-30 06:41:18
+3
A:
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");
}
Dmytrii Nagirniak
2009-11-30 06:48:45
do we need to download this 'http://jqueryui.com/demos/dialog/', to use your example ?
Rakesh Juyal
2009-11-30 07:03:49
Yes. The sample relies on the dialog from jQuery UI.
Dmytrii Nagirniak
2009-11-30 10:50:03