Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » HTML-CSS-PHP-JavaScript / JavaScript Codes » JavaScript Confirmation POPUP To Run Next Function Or Go Back

JavaScript Confirmation POPUP To Run Next Function Or Go Back

A confirmation dialog box is mostly used to take user’s consent on any option. It displays a dialog box with two buttons: Cancel. If the user clicks on the OK button, the window method confirm() will return true. If the user clicks on the Cancel button, then confirm() returns false. You can use a confirmation dialog box as follows.

  • VAR: means VARIABLE. A temporary storage place.
  • ANSWER: is the name of that storage place. Depending on the visitor’s response, the ANSWER will hold either a TRUE or FALSE value.
  • CONFIRM: creates the actual pop-up box with an OK and CANCEL choice. OK is used for a TRUE response. CANCEL is used for a FALSE response. The text area following is used as the prompt text on the box. Usually a true/false type question.
  • IF() ELSE: This determines what happens according to the input. It looks at the storage cell called ANSWER. IF it is a TRUE value, it does the first set of instructions. ELSE it is a FALSE value, so do this other set of instructions.

To get the CONFIRM actions to perform, we have to use a VARIABLE situation to control it. That means, we have to use a bit of algebra to temporarilly assign a value to the visitor’s answer choice. After the value (answer) is determined, the script then carries out the set of instructions accordingly. This is usually done with an IF…ELSE statement. IF the answer is true, do this. ELSE the answer is false, so do this instead.

Table of Contents

Recommended For You:
Simple And Clean Double Value CSS Badges And Labels Examples


1.) Pure JavaScript Added.
2.) No JQuery File.
3.) No HTML-CSS Added.
4.) Simple And Fast Loading Code.
5.) Can Work With Any Browser.

How To Add In A WebPage?

1.) Just Go To Your “Web Page File”.
2.) Now “Copy” The Below Codes And “Paste” It To There Positions.
3.) “Save” It, Now You Are Done.


<script type="text/javascript">
var answer = confirm('Do You Confirm Want To Run The Next Function/Step?');
if (answer){
alert("Yes, You Moved Ahead.");
} else {
alert("LOL, You Moved Backward.");


1.) Edit Your JavaScript As Per Your Requirements. Rest Is Ok For General Us. If You Are Pro, Then You Can Do Any Thing.

Last Words:

That’s all we have. If you have any problem with this code in your template then feel free to contact us with full explanation of your problem. We will reply you as time allow to us. Don’t forget to share this with your friends so they can also take benefit from it and leave your precious feedback in our comment form below. Happy blogging, See you in next article…

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *