September 2, 2009

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;”>

Finding a file path

Posted in Coldfusion at 6:25 pm by borawlings

I found the easiest way to check a file path is to use:

<cfoutput>#GetTemplatePath()#</cfoutput>

This really helpful for upload utilities because the above command will return the exact path to the upload directory.

Reusing code with CFINCLUDE

Posted in Coldfusion at 6:19 pm by borawlings

Reusing code with CFINCLUDE

 The CFINCLUDE function is a great way to share code throughout your application.  I usually use this code to share buttons throughout forms within applications.  That way if I need to make a change to a button’s link, I only have to change the code in one place and the change is shared throughout my application wherever the buttons are needed.

 Here’s the code for BTNS_ADMIN.html. 

<input value=”Sponsored Progs”/>

<input value=”William and Mary”/>

<input value=”Places to Stay”/>

 When this code runs, three buttons are displayed.  Each button has an “onclick” attribute set to a particular location.

 Now, CFINCLUDE is used to call BTNS_ADMIN.html on the form

FRM_Show_buttons.cfm:

 <!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=iso-8859-1″ />

<title>Untitled Document</title>

</head>

 <body>

<cfinclude template=”BTNS_Admin.html”>

</body>

</html>

 And that’s it!!!

Follow

Get every new post delivered to your Inbox.