Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formating number in output

Status
Not open for further replies.

aggregate

Programmer
Joined
Oct 2, 2003
Messages
13
Location
US
I have the following script

function slabCalc(form) {
l = eval(form.length.value);
w = eval(form.width.value);
d = eval(form.depth.value);
dinches = eval(d/12);
cu = eval((l*w*dinches)/27);
form.cu.value = cu

}

That calculates amount of concrete need by using form vars. The only problem I have is that the result is display with to many digits after the decimal. I only want to display 2.

Any help would be great
 
Change your last line to:

form.cu.value= Math.round(cu*100)/100

MrGreed

"did you just say Minkey?, yes that's what I said."
 
Or you could use the toFixed() method

formName.Name.value.toFixed(2)



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top