We alert user using this javascript, now i want to add this functionality to my html form, which sends the data using the post method to my php form processing page.
Now what i want is to terminate the action if the user presses cancel button, it means all the data which has been sent using the post method should not be sent and the person would not be able to process the form until and unless he/she clicks the OK
button. So is it possible? Or it is just some idiot question?
<html>
<head>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button!");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="Show a confirm box" />
</body>
</html>