#DollarFormat(intTotal)# in coldfusion?

LelloLello
LelloLello used Ask the Experts™
on
I have a question what the #DollarFormat do in my CFMAIL ? and why I need it.

<cfmail from="#form.strEmail#"
                                    " type="html">
-------------------------<br>
Name: #strBadgeName#  <br>
Company:  #FORM.strCompany#<br>
Address: #FORM.strAddress# #FORM.strCity# #FORM.strProvince# #FORM.strPostal#
Phone: #FORM.strPhone#<br>
Fax: #FORM.strFax#<br>
Email: #Form.strEmail#<br>
-------------------------<br>
Registration Information:<br>
-------------------------<br>
Subtotal: #DollarFormat(intSubTotal)#<br>
#tax_label#: #DollarFormat(intGST)#<br>
Tax Exempt: #intGSTNumber#<br>
Total: #DollarFormat(intTotal)#<br>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dollar format takes the number passed in the variable and displays it as a decimal with a dollar sign, like this:   $1,000.00
without dollar format, it would look like this:   1000

It is just a way of formatting a numer to look like money

Author

Commented:
okay... this is my front end page:

<fieldset><legend>Registration Fees</legend>
                                          
                              <br>
                   
                   <table border="0" cellspacing="0" cellpadding="0" width="100%">
                              <tr>
                                    <td width="98%" valign="top"><label for="intOption575">Subscription</label></td>
                                    <td width="1%"><cfoutput><cfset intRate = int(val(getRates.rate))>
<input type="radio" name="intOption" id="intOption575" value="#intRate#"  onClick="Calculate_Sub_Total(this)" class="formWidget"></cfoutput></td>
                                    <td width="5"><img src="images/spacer.gif" height="1" width="5" border="0" alt=""></td>
                                    <td width="1%" nowrap><label for="intOption575">$<cfoutput query="getrates">#getRates.rate#</cfoutput></label><cfoutput><input type="hidden" name="intOption" id="intOption1" value="#intRate#"  class="formWidget"></cfoutput></td>
                              </tr>

this is the backend...

<!---get rates--->
<cfset today = parseDateTime(dateFormat(now(), "yyyy-mm-dd"))>
<cfquery name="GetRates" datasource="#application.datasource#" username="#application.username#" password="#application.password#">
  SELECT *
  FROM CIANET_Rates
  where startDate <= #today#
AND    (     endDate >= #today#  OR  endDate is NULL )
</cfquery>

      <cfset intSave_val = 0>
<cfset intSubTotal = #getRates.rate# >

So in my cfmail function
Subtotal: #DollarFormat(intSubTotal)#
#tax_label#: #DollarFormat(intGST)#
Tax Exempt: #intGSTNumber#
Total: #DollarFormat(intTotal)#

I have to take out the dollarformat because it gave me error. any idea?
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Author

Commented:
could u pls advise on my other quesiton.
>  have to take out the dollarformat because it gave me error. any idea?

I think the only way for it to error is if the value passed is not a number

You can ensure it is a number by using val()  

    DollarFormat(val(intSubTotal))

but that may hide bugs if the value is not correct

Author

Commented:
so i should keep i then thank u.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial