Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > 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 | ![]() ![]() ![]() |