Confirmation dialog Box is used to get confirmation on any input. It is mostly used to take user's opinion on any option. It displays a dialog box with two buttons: Cancel and OK.
If the user clicks on the Cancel button, then confirm() returns false.
Similarly when the user clicks on the OK button, the window method confirm() will return true.
Have a look on this simple example to understand the concept of confirmation dialog box: -
<body>
<p>Click on the button below to confirm </p>
<form>
<input type="button" value="Click Me" onclick="getConfirmation();" />
</form>
<script type="text/javascript">
function getConfirmation(){
var retVal = confirm("Do you want to continue ?");
if( retVal == true ){
document.write ("Reeady to continue");
return true;
}
else{
document.write ("Not ready to continue");
return false;
}
}
</script>
</body>
0 Comment(s)