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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i need to perform a calculation on

Status
Not open for further replies.

WebGodiva

Technical User
Jun 21, 2000
263
0
0
US
i need to perform a calculation on two form values to submit the result.

The code I'm working with is:

<cfset rate1 = #form.NewSalary#*2080>
<cfset rate2 = #form.OldSalary#*2080>
<cfset PercentRateChange = rate1/rate2>

<cfoutput>#form.NewSalary#</cfoutput>
<br>
<cfoutput>#form.OldSalary#</cfoutput>
<br>
<cfoutput>#PercentRateChange#</cfoutput>

This is in my results page. What I'm having the problem with is teh #PercentRateChange# is calculating ok but not at the right percent level. When I divide 60000.00 by 20000.00 I get 3 as the percent level and it should be 30.

Is there a simple solution to this?

Thanks Hope this helped!
 
Hi WebGodiva,

It looks like your problem is a simple math problem. When you divide 60,000 by 20,000, the answer IS 3. If you want that to be represented in the form of a percentage, just multiply by 100, and in this case you get 300%. The amount 60,000 IS 300% of 20,000!

Dave.
 
Thanks for your quick response - if I had a brain sometimes I'd be dangerous.

You were correct, I then formated the #DecimalFormat(PercentRateChange)# and it even gives me the decimal places.

Thanks again. Hope this helped!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top