Open Tech Support
Open Tech Support Archives
Back to HomeCommunityReviewsGuidesDownloadsTech LinksMarketplaceContact Us
 »  SITE NAVIGATION
»  OTS Home
»  OTS Forums
»  OTS Archives

»  About our site
»  Search our site
»  Support our site

»  What is this site?
»  Who are we?
 
 
 »  ADVERTISMENT
 
  Pages: 1

Javascript Rounding

(Click here to view the original thread with full colors/images)


Posted by: Cal32

Does anybody know hw to get this code to round to the nearest integer?

function calculateTotal(formToUse) {
var Coffee = parseFloat(formToUse.coffeeBox.value)
var Cigarette = parseFloat(formToUse.cigaretteBox.value)
var Movie = parseFloat(formToUse.movieBox.value)
var Smoothie = parseFloat(formToUse.smoothieBox.value)
var Coat = parseFloat(formToUse.coatBox.value)
var Shoe = parseFloat(formToUse.shoeBox.value)
formToUse.totalOutputBox.value = (((Coffee*1.13)+(Cigarette*3.31)+(Movie*7.68)+(Smoothie*3.71)+((Coat-1)*60/24)+((Shoe-1)*30/6))/(3.63*14))

}



Posted by: DemonBob

The command is round() I believe
used like this y = Math.round(x)



 
Copyright 2000-2008 Open Tech Support.  All Rights Reserved.  Site Design and Development by Tolitz Rosel.