[Javascript] Math

Cutter Bl cutterbl at hotmail.com
Thu Aug 16 13:34:14 CDT 2001


Ben,
     Thanks so much. Works like a charm. I even adjusted the function so 
that I could pass the Price and Discount to the function [fTotal = 
tixPrice(fields[0],fields[1],fields[2])] so if I ever change the price and 
discount in the database it will automatically handle the function.

function tixPrice(Qty,Price,Disc) {
     var Discounted = parseInt((Qty) /3) *(Disc);
     var RegPrice   = (parseInt(Qty) %3) *(Price);
     return (Discounted + RegPrice);
}

Cutter
http://www.falcon-knives.com
****************************************
From: Ben Curtis <Quixote at LaMancha.org>
Reply-To: javascript at LaTech.edu
To: <javascript at latech.edu>
Subject: Re: [Javascript] Math
Date: Thu, 16 Aug 2001 09:24:33 -0700


 > have a form text field where the user can enter the Quantity
 > (myForm.Quantity). Here's the kicker. The client says $2 a ticket, 3 for 
$5.
 >
 > Ok, so 10 tickets is $17. 10 divided by three is 3.33333etc. 3 times 5 is
 > 15, plus the $2 for the other ticket.
 >
 > But how do you put this in a script calculation?

function tixPrice(Qty) {
     var Discounted = parseInt(Qty /3) *5;
     var RegPrice   = (parseInt(Qty) %3) *2;
     return (Discounted + RegPrice);
}

--
+Ben Curtis

"On the other side of the screen, it all looks so easy."






_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
http://www.LaTech.edu/mailman/listinfo/javascript


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




More information about the Javascript mailing list