[Javascript] Math

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


Ben,
     Thanks for your suggestion. This didn't quite work, But Ben Curtis 
helped me out (I included the working code in my response). What is 
Math.floor?

Cutter
http://www.falcon-knives.com

*******************************
From: staeger <staeger at arch.ethz.ch>
Reply-To: javascript at LaTech.edu
To: javascript at LaTech.edu
Subject: Re: [Javascript] Math
Date: Thu, 16 Aug 2001 18:15:39 +0200

Cutter Bl wrote:
 >
 > I'm terrible at Math as it is, but I still don't understand javascripts 
math
 > operations real well anyway. Any help here is greatly appreciated.
 >
 > I've got a non-profit who wants to sell Raffle Tickets from their site. I
 > 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?
 >
 > Cutter
 > http://www.falcon-knives.com

i'm just trying it ...

var tickets = [number off tickets];
price = 5*Math.floor(tickets/3) + 2*(tickets%3);

greets./

--
-----------------------------------------------------------------
benjamin staeger            swiss federal institute of technology
                                               architecture & caad
                                       mailto:staeger at arch.ethz.ch
                                 http://caad.arch.ethz.ch/~staeger
-----------------------------------------------------------------
                       Always  listen  to  experts.
They'll  tell  you  what  can't  be  done,  and  why.  Then do it.
_______________________________________________
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