Use ToFixed(2)
mdn
(123.00 + 12.00).toFixed(2)
//135.00
Also , use || operator.
So :
function addNumbers()
{
var collect = parseFloat(document.getElementById("Collect").value) ||0;
var current = parseFloat(document.getElementById("Current").value) ||0;
var Balance = document.getElementById("Bal");
Balance.value = (collect + current).toFixed(2);
}
Small gotcha :
(9.999 +9.999).toFixed(2)
//"20.00"
So how would I solve it ?
simply :
Multiply by 1000 each and then move decimal point.