Skip to main content
April 26, 2011
Question

output to 2 decimal places

  • April 26, 2011
  • 1 reply
  • 1233 views

Hi there,

Got a small problem the output's are coming out like this 155.5 and i need them to come put like this 155.50

<cfparam name="FORM.twin" type="string" default="1" />

---------------------------

<cfquery name="twin" datasource="strand">
SELECT *
FROM hotel_rooms
WHERE hotel_rooms.ID = 1</cfquery>

---------------------------

<!---Twin CFIF--->
<cfif form.twin gt "0" and form.nights eq "1">
<cfset tprice = 1*#twin.price_night1#>

<cfelseif form.twin gt "0" and form.nights eq "2">
<cfset tprice1 = 2*#twin.price_night1#>
<cfset tprice = #tprice1#*0.95>

<cfelseif form.twin gt "0" and form.nights eq "3">
<cfset tprice1 = 3*#twin.price_night1#>
<cfset tprice = #tprice1#*0.90>

<cfelseif form.twin gt "0" and form.nights gte "4" and form.nights lt "8">
<cfset tprice1 = #form.nights#*#twin.price_night1#>
<cfset tprice = #tprice1#*0.85>
</cfif>

---------------------------

<cfoutput>#tprice#</cfoutput>

Any one any ideas.

Thanks

Jonathan Hemmings

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    April 26, 2011

    You will want to look into numberFormat(). Here is the URL: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-72c8.html

    April 26, 2011

    I have tried this:

    <cfoutput>#numberFormat(tprice,”-£____.__”)#</cfoutput>

    But i keep geting this error:

    The following information is meant for the website developer for debugging purposes.

    Error Occurred While Processing Request 
    Invalid construct: Either argument or name is missing. 
    When using named parameters to a function, each parameter must have a name.
    The CFML compiler was processing:

    An expression beginning with numberFormat, on line 269, column 57.This message is usually caused by a problem in the expressions structure.
    The body of a cfoutput tag beginning on line 269, column 47.
    The body of a cfoutput tag beginning on line 269, column 47.

    Am i using it wrong?

    Thanks

    Jonathan hemmings

    April 26, 2011

    Fixed

    <cfoutput>#LSNumberFormat(dprice,',99999999999999.99')#</cfoutput>

    Cheers

    Jonathan