'Yes', 'No', and Cancel with JavaScript confirm function - javascript

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.

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

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

Related

Laravel Confirm Dialog

I'm looking for a simple way to confirm a delete of an item (I'm using Laravel 5.3)
I have this code:
<span class="glyphicon glyphicon-trash"></span>
So when clicking on the link, I call the route deleteProduct/{id}. But what I want is, that when clicking on the link, there is a prompt, saying something like sure to delete? yes/no. Only when clicking yes, this route is called then.
I tried it with a bootstrap modal and in general it worked, but I had problems with the $product, actually $product is an item in a foreach, so around the <a>-tag, there is a #foreach($products as $product). That's why the modal didn't work, because it got somehow messed up with this foreach (actually $product always held the last "product", because i defined it after the foreach).
Is there a easy to achieve what I want? Alternatively I could create a modal for every product, but there could be up to thousands of those, so this would be nonsense. So whats the better way?
Edit: The normal javascript function confirm() would work, but thats a little "too basic", so I want something that fits in the design, so something with bootstrap would be nice, or anything thats not a alert dialog with two buttons. The functionality of confirm is the one that I want. But also, confirm provides the buttons in english, I may want to customize those to be used in more then one language.
I have achieved a pretty great results with SweetAlert plugin. There is actually an example of a delete with ajax. Check it out!

extjs 3.4 How to use prompts UI?

I have a requirement of not using radio buttons to track a 'Yes' or 'No' option in a dialog box. Instead use something like a prompt which will have Yes, No and Cancel as prompts. (No explicit Submit button unlike in the above case). Is there anyway to do this using extjs 3.3/3.4?
I have been reading the documentation but do not see any support for prompts. Any help or ideas on this will be greatly appreciated.
Thanks
there is Ext.Msg library to use.
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.MessageBox

Use JavaScript to disable all buttons on a page until a refresh

I have a page that will cause an error if a user tries to click too many buttons at one time (for the impatient user) and therefore need to DISable any button (all defined by a JS onclick function) on the page until it is refreshed (with new data sent via the server using Java.) What is the best method to do this, and is there a way to do it with jQuery?
You would have to find all types of buttons using something like this..
$('input[type="submit"], button')
and loop through the returned array and do .attr('disabled','disabled'); on the item in each iteration.
How about simply calling this when you want to disable the buttons:
jQuery('input[type="button"]').attr('disabled', 'disabled');
That will disable all inputs of type button on the page. Of course, as soon as you reload/replace the page contents, the new buttons will not be disabled. You can also just disable all inputs if that's easier.
Fiddle: http://jsfiddle.net/duffmaster33/xDMux/
The single best solution is to use the BlockUI plugin for jQuery. It accomplished everything I needed and more. http://www.malsup.com/jquery/block/

can you alter the button titles on javascript confirm?

Just wondering if there was an easy way to change the 'yes', 'cancel' titles on the confirm box window in javascript? Just seems a bit limiting if not!
The Yes, No, Cancel is a browser's basic feature, which cannot be modified. But you can make alternates like: Yes or No confirm box using jQuery

JQuery / Javascript popup box and form submission creation

I have a jquery/javascript question. For a site I am working on in PHP/JQuery I have the need to create a dialogue box with an ok/cancel button and a message and then submit a form based on if the user says ok or not. I know in javascript I can create a new window that links to a styled page and then I can do a select for if the user hits the ok button and submit the windows parent form using that but the last time I coded something similar to it I felt like it took a lot of lines of code and was wondering if JQuery supported dialogue box creation and if I could do some similar functionality using it (with hopefully less lines of code since everytime I use jquery instead of standard javascript it seems like it really reduces my codebase). If anyone knows of a resource to learn how to do this I would appreciate a link or a second of your time for some pointers.
Thanks!
I think you are looking for something along the lines of the jquery ui dialog.

Categories