Quantcast
Channel: Adobe Community : Discussion List - ColdFusion
Viewing all articles
Browse latest Browse all 6243

How do I use cfloop to insert numbers that are not rounded?

$
0
0

I ran the following code and it displayed my numbers correctly, ie: 1.75, 2.50:

 

<cfloop from="1" to="#getnumba#" index="idx">

    <cfset getunit = form["unit" & idx]>

<cfoutput>#NumberFormat(getunit, "99.99")#</cfoutput><br />

</cfloop>

<cfabort>

 

But when I tried the following code, it rounded the numbers again:

 

<cfloop from="1" to="#getnumba#" index="idx">

               <cfset getqty = form["qty" & idx]>

    <cfset getitem = form["item" & idx]>

    <cfset getunit = form["unit" & idx]>

              

<cfif (getqty is "") and (getitem is "") and (getunit is "")>

               <cfset getqty = 0>

    <cfset getitem = 0>

    <cfset getunit = 0>

</cfif>  

              

<cfquery name="insertItems" datasource="#application.dsn#">

INSERT into items

(orderID,

               qty,

               item,

               unit

)

VALUES(

<cfqueryparam value="#getoid#" CFSQLType="CF_SQL_INTEGER" >,

<cfqueryparam value="#getqty#" CFSQLType="CF_SQL_INTEGER" >,

<cfqueryparam value="#getitem#" CFSQLType="CF_SQL_VARCHAR" >,

<cfqueryparam value="#NumberFormat(getunit, "99.99")#" CFSQLType="CF_SQL_INTEGER" >

)

</cfquery>

 

</cfloop>


Viewing all articles
Browse latest Browse all 6243

Trending Articles