PDA

View Full Version : How to display trailing zero's after multiplication



anur115
02-08-2012, 06:36 PM
I have javascript function which calculates the product of two numbers.


function fnCalculate()
{

var lat1=price * num;

}
Here for eg if price is 19.50 and num is 1 then o/p should be 19.50 and not 19.5 as its resturning now.

Also if price is 15.00 and num is 1 then o/p should be 15.00 and no just 15.

Is it possible ... someone please help

jscheuer1
02-08-2012, 08:26 PM
See:

http://www.w3schools.com/jsref/jsref_tofixed.asp

Like:


var lat1 = (price * num).toFixed(2);