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!

calculating percent from total

Status
Not open for further replies.

bcardona

Programmer
May 10, 2001
103
0
0
US
it has been a while since i did this and dont remember, how to take say 10% of a total price, your help is appreciated
 
Multiply by 0.1 ?

Is this a trick question?
 
no not a trick question, its been a while since i did classic asp, dont take the numbers i used literally, heres an example.

if a product is $25.00 and the percent off is 6% what is the total.
 
sorry i was told wrong what i need is, say a product is 12.99 but will sell for 10.50, what percent did they save.
 
do i have to use formatcurrency or anything like that
 
That depends on how you want it displayed.
 
what i am trying to do, is for instance we have a product say for 11.99 then it says buy now for 8.50 then it says you saved whatevery percent, this is what i need to have it say as an example 30%, i think i have the calculation right, im not sure if some already has it done and would pass it along i would appreciate it, also i cant remove the decimal from the percentage here is my code for the percent

formatpercent(variable,2) it displays .12%. thanks in advance
 
The various functions that you need are all referenced in detail at
To save you looking them up try
Code:
<p>Normal price 10.99 - our price 8.50 - you save <%=round(100*((10.99-8.5)/10.99),0)%>%</p>

Use that and the reference site, along with the previous answers to work out how it all works. If you have any more questions read faq222-2244 for guidance on forum usage and basic research, then post again.

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
You could make a function:
makePriceLine()

It could accept price a, price b, discount

Then you could have the logic:

IF price a and price b are set:
check difference and calculate if there is a discount

IF price a is set or price b is not set and discount is set:
calculate price and give discount

RETURN:
price a (inside a span with css style strike-through and red font)
price b
discount

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top