Wednesday, September 14, 2011

Javascript Confirm Message Box

This is the simple and easiest way to create a JavaScript confirm message box. A JavaScript confirm message box is similar to an alert box.with the JavaScript confirm message box the user can get two choices — OK and Cancel button in the message box. One ristriction with the JavaScript confirm message box is that You can't change the names of the choices but you can determine what they do.

<html>
<head>
<script type="text/javascript">
function showConfirmBox()
{
     var r=confirm("Kindly Press a button!");
     if (r==true)
    {
         alert("You just pressed OK!");
    }
   else
   {
        alert("You just pressed Cancel!");
    }
}
</script>
</head>
<body>
<input type="button" onclick=" showConfirmBox ()" value="Click here for confirm box" />
</body>
</html>