Monday, January 13, 2014

confirm(whatever); is like alert(whatever); in JavaScript but with OK and Cancel buttons bolted onto the dialog box.

You can always close the dialog box with the X instead of explictly clicking Cancel so the example at w3schools.com here is sort of misleading as it suggests a result other than OK comes only from clicking Cancel. I made my own example which is better. It is:

var result = confirm("I'm OK with a meningitis vaccine.");
if (result)
{
   alert("You picked OK.");
} else {
   alert("You did NOT pick OK.");
}

No comments:

Post a Comment