09.02.09

Alert : Confirmation

Posted in Alerts, Javascript at 6:32 pm by borawlings

This script goes before the body tag:

<script type=”text/javascript”>

<!—

function confirmation() {
 var answer = confirm(“Run this sucker!”)
 if (answer != 0){
    alert(“This sucker is running!”)
    document.myformname.submit();
}
else {
           alert(“This sucker canceled!”)

          }
}
//–>
</script>

This script is launched when the user clicks the “Submit” button on a form.  The user is presented with a pop-up box.  If “yes” in responst to “Run this Sucker!”, then the form is submitted by the document.reports.submit() function, where “reports” is the name of the form.  The statement is what kicks off the action “myquery.cfm”.  Otherwise, nothing happens.

Here’s what the cfform tag looks like:
<cfform name=”myformname” action=”myquery.cfm” method=”post” id=”myForm” onsubmit=”confirmation();return false;”>

Leave a Comment