Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

division/percentages 1

Status
Not open for further replies.

nsampson1

IS-IT--Management
Sep 8, 2000
26
GB
I feel embarrassed having to ask such a basic question but can anyone tell me how to find a percentage of a numeric variable in coldfusion, or simply how to divide one numeric variable by another numeric variable?

eg

<CFSET Number1=10>
<CFSET Number2=5>

<CFSET Result=#Number1# / #Number2#>

The above code obviously doesn't work as '/' has a defined purpose in coldfusion.
 
that should work ... maybe drop the #'s?

<cfset number1=5>
<cfset number2=10>

<cfset result=number1/number2>

- Marc
 
thanks marc

it's amazing what a simple syntax change can do. I'd never considered removing the # signs.
 
Remember, pound signs (shift-3) are only needed when you want CF to evaluate the variable before the tags that surround it are executed.

You need them here:
<CFQUERY>
select F from T
where T = #TID#
</CFQUERY>

and here:
<CFSET fname = &quot;Jack&quot;>
<CFSET lname = &quot;Black&quot;>
<CFSET whoAmI = &quot;#fname# #lname#&quot;>

and here again:
<CFLOOP from=&quot;1&quot; to=&quot;#listLen(nameList)#&quot; index=&quot;i&quot;>
</CFLOOP>

not here:
<CFSET nameList = &quot;&quot;>
<CFSET nameList = listAppend(nameList, whoAmI)>

nor here:
<CFSET whoAmI = fname & &quot; &quot; & lname>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top