[thelist] Javascript - round to 2 decimal points
Bob Meetin
bobm at dottedi.biz
Fri May 22 21:23:03 CDT 2009
Tim Snadden wrote:
>
> On 23/05/2009, at 12:47 PM, Bob Meetin wrote:
>
>> I have a simple script that does a volume calculation if you enter the 3
>> values of length, width, height. see it at
>> http://dottedi.biz/codesamples/volume_calc.html
>>
>> What I don't know how to do is to use "tofixed(2)" in the script to set
>> the number of decimal points to 2 in the Cubic Yards output.
>>
>
> Hi Bob. It's case sensitive and need to be toFixed rather than
> tofixed. Also it needs to operate on a number rather than a string. Try
>
> parseInt(myform.cuyd.value).toFixed(3)
>
> Hope that helps. Cheers, Tim
>
Thx. Closer but no seegars. This trims to the correct number of
decimal points but also rounds whatever is after the decimal points down
to .00. Input 7, 7,13 and tab to see the results.
Over, Bob
--
Bob Meetin
www.dottedi.biz
303-926-0167
On www.Twitter.com/bobmeetin, Facebook, www.linkedin.com/in/bobmeetin, or catch my blog at www.dottedi.biz/blog.php
Standards - you gotta love em - with so many to choose from!
More information about the thelist
mailing list