[thelist] Javascript - round to 2 decimal points

Bob Meetin bobm at dottedi.biz
Fri May 22 19:47:02 CDT 2009


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.

	<script language="javascript">

		function calculate()
		{
			myform.cuin.value = (myform.l1.value * 12) * (myform.w1.value * 12) * (myform.h1.value );
			myform.cuft.value = myform.cuin.value / 12 / 12 / 12 ;
			myform.cuyd.value = myform.cuft.value / 27 ;
 			myform.cuyd.value =  (myform.cuyd.value).tofixed(3);
	 
			// var num = 10;
			// var result = num.tofixed(2);
		}

	</script>

Just a wee bit of Friday night help please.

-Bob




More information about the thelist mailing list