https://dev.webpages.dk/  
 
About Javascript Confirm
How to use Javascript Confirm:

A confirmbox is a popup message where you have the possibility to select 'Okay' or 'Cancel'.

This give you some possibilities to get input from your users. Let's say if you want to give them a warning, and confirm, the deletion of a file or some database entry.

Try the running example to the right.

 Javascript Confirm

This Javascript will show you a Javascript Confirm box and read you response, and then tell you what you just clicked.



A Javascript Confirm is a box that will popup and give you the choice of selecting 'Cancel' or 'OK'.
Then you can check to see which button your user have clicked.
You do this by assigning a variable to the confirm, and then check to see if that variable turned out 'Cancel' or 'OK.' (false or true). You can place your code to then react on that choice. That makes it a confirmbox as you either get users accept or the opposite, to a question you may ask.
(Is it okay to delete this file?)

 HTML

<input id="clickMe" type="button" value="Click me to execude the script.." onclick="runmenow();"></button>

 Javascript

<script>
    function runmenow () {
        var yesno = confirm("Welcome to the webdeveloping site" );
        if (yesno == true) { alert("You clicked OK..."); }
        if (yesno == false) { alert("You clicked Cancel..."); }
    } 
</script>

 And if you have problems with the script being executed twice, then you can go this way:

<script>
    function runmenow () {
        var called = false;
        if (!called) {
            var yesno = confirm("Welcome to the webdeveloping site" );
            if (yesno == true) { alert("You clicked OK..."); }
            if (yesno == false) { alert("You clicked Cancel..."); }
            called = true;
        } 
    } 
</script>

 PHP

Icons made by Freepik from www.flaticon.com This example shows you how to use a JS confirm. With this you have two choices, 'OK' and 'Cancel' and can react to them.
07:40:00