Use the DollarFormat( ) function to format values with a dollar sign, a thousand separator, and 2 decimal places. Its syntax is:
DollarFormat(NumericValue)
This tells ColdFusion to return function results rather than the function name to the browser.
The two code sets below display $23,333.44 in a browser:
<CFOUTPUT>
#DollarFormat(2333344)#
</CFOUTPUT>
<CFSET Salary=DollarFormat(2333344)>
<CFOUTPUT>
#Salary#
</CFOUTPUT>
The code below formats the Salary column data that was returned from a query performed earlier on the same page:
<CFOUTPUT QUERY="EmpList">
#DollarFormat(Salary)#<BR>
</CFOUTPUT>
| To format currency for display: |
#DollarFormat(Salary)#
The Salary is formatted for page display.
Click here to see how the page should look at this time.
Click here to see the code behind the scenes.
| Note: | The navigation links will not work at this time. |