I have a customized confirmation message box that pops up when a cfform is submitted. My code is below. My problem is the code doesn't wait for the user to confirm the submission. The message box pops up temporarily and then the form is submitted without the user selecting a button.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
//Function to show results of other message boxes.
var showResult2 = function(btn){
if (btn == 'yes'){
alert("You clicked Agree button: "+btn);
}
else{
alert("You clicked Cancel button: "+btn);
}
}
//The button onClick handler displays the message boxes.
function showMB(mbox) {
ColdFusion.MessageBox.show
(mbox);
}
</script>
</head>
<body>
<cfform name="dg" action="test.cfm">
<p>Click a button display the corresponding message box.</p>
<cfinput name="Prompt" type="submit" value="Submit" onclick="showMB('mymessage
box02')">
</cfform>
<!--- Code to define the message boxes. --->
<cfmessagebox name="mymessagebox02" bodystyle="font-family: Arial, Helvetica, sans-serif" type="confirm" title="Warning:"
message="Are you sure you want to proceed?"
labelNO="Cancel" labelYES="Agree"
callbackhandler="showResul
t2"/>
</body>
</html>
Then in your pop up message, when the user agrees, that button press action should submit the form..