views:

117

answers:

4

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: 

How about using a JQuery dialog?

Suppressingfire
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
+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
do we need to download this 'http://jqueryui.com/demos/dialog/', to use your example ?
Rakesh Juyal
Yes. The sample relies on the dialog from jQuery UI.
Dmytrii Nagirniak
A: 

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.

NilColor