Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > A User-defined function example PreviousNext

A User-defined function example

The following simple function takes a principal amount, an annual percentage rate, and a loan duration in months and returns the total amount of interest to be paid over the period. You can optionally use the percent sign for the percentage rate, and include the dollar sign and comma separators for the principal amount.

You could use the TotalInterest function in a cfoutput tag of a form's action page, as follows:

<cfoutput> 
   Loan amount: #Form.Principal#<br>
   Annual percentage rate: #Form.AnnualPercent#<br>
   Loan duration: #Form.Months# months<br>
   TOTAL INTEREST: #TotalInterest(Form.Principal, Form.AnnualPercent,
Form.Months)#<br> </cfoutput>

Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > A User-defined function example PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.