my sums are not adding up? please help.

G

Guest

if the values of the following are already set from an order form in another
iframe.

cKiwiFruit=18
KiwiFruit=17


i need a line to calculate to cost of the special offer, kiwi's are 18pence
each but buying 7 you only pay £1.00. so buying 17 would be 2 lots of £1.00
for the first 14 and then 18pence each for the remander (3 * 18pence) a
total of £1.54pence.

total=eval(((int)(form.KiwiFruit.value/7)*100)+(((int)(form.KiwiFruit.value/7)*7)*cKiwiFruit));


thanks
 
S

Steve Easton

You need to remember the "My Dear Aunt Sally" rule" Multiply, divide, add and subtract.

so try:
subtotal1 = eval((int)(form.KiwiFruit.value/7)*100;

subtotal2 = eval (((int)(form.KiwiFruit.value/7)*7)*cKiwiFruit));

total = subtotal1 + subtotal2;


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
G

Guest

sorry did not work.

any other ideas please.



Steve Easton said:
You need to remember the "My Dear Aunt Sally" rule" Multiply, divide, add
and subtract.

so try:
subtotal1 = eval((int)(form.KiwiFruit.value/7)*100;

subtotal2 = eval (((int)(form.KiwiFruit.value/7)*7)*cKiwiFruit));

total = subtotal1 + subtotal2;


--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
.......................with a computer
 
G

Guest

does the (int) do what i think it does, rounds the figure down to
the nearest full number. (no decimal)
 
J

Jon Spivey

Hi,

The sums in your question don't add up - 17 would be £2.54 :) There's no
int in javascript., try it like this

NumberOfKiwis = 17;
var a = Math.floor(NumberOfKiwis/7);
var Total = a * 100 + ((NumberOfKiwis-(a * 7)) * 18);
alert(Total) // 254

You'd probably want to divide total by 100 to get pounds and pence then
stick a £ sign in front of it

--
Cheers,
Jon
Microsoft MVP


total = Math.Floor(NumberOfKiwis/7) * 100 +
 
G

Guest

thank you, it work, perfectly.

cheers.


Jon Spivey said:
Hi,

The sums in your question don't add up - 17 would be £2.54 :) There's no
int in javascript., try it like this

NumberOfKiwis = 17;
var a = Math.floor(NumberOfKiwis/7);
var Total = a * 100 + ((NumberOfKiwis-(a * 7)) * 18);
alert(Total) // 254

You'd probably want to divide total by 100 to get pounds and pence then
stick a £ sign in front of it

--
Cheers,
Jon
Microsoft MVP


total = Math.Floor(NumberOfKiwis/7) * 100 +
 
S

Steve Easton

LOL.
My Dear Aunt Sally goes waaaaayyyyy back to the days of DOS
But, it still works for me.
;-)



--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top