2

I am familiar with the basic JavaScript confirm function. I want to take one step further: instead of having a message box pop up with the options of "OK" and "Cancel", I would like to add three options and change the dialog so that the three choices read "Confirm", "Deny", and "cancel". A "Confirm" or "Deny" choice would each call a different function. Any suggestions on how to do this?

I am not using JQuery or any other library, and i really don't want to use any if I can help it, as it's just this one function. Any help would be appreciated.

Anonymous
  • 21
  • 1
  • 2
  • Dup: http://stackoverflow.com/questions/1800033/custom-choices-in-javascript-confirm-dialog – Ray Toal Jul 28 '11 at 18:01
  • Possible duplicate of [how to show confirmation alert with three buttons 'Yes' 'No' and 'Cancel' as it shows in MS Word](http://stackoverflow.com/questions/9091001/how-to-show-confirmation-alert-with-three-buttons-yes-no-and-cancel-as-it) – David Millar Mar 08 '17 at 21:43

2 Answers2

2

You will want to look into making a custom dialog from a div, and assign click events to the buttons. You can't modify the browser's standard dialogs without using VBScript which is IE only.

The fact that you don't want to use JQuery is quite silly. It's 31k and the best thing to ever happen to JavaScript.

If you want to avoid JQueryUI, you can create a dialog yourself very easily. Here's a tutorial to get you started: http://www.queness.com/post/1696/create-a-beautiful-looking-custom-dialog-box-with-jquery-and-css3

AlienWebguy
  • 76,997
  • 17
  • 122
  • 145
2

AFAIK, you cannot change the button prompt strings with just using pure JS. It has to be 'OK' and 'Cancel'.

Basanth Roy
  • 6,272
  • 5
  • 25
  • 25