I have a bit of javascript that dynamically multiplies what users are typing in a text field (by the base var), and displays it in a Now I'm just trying to figure out how to get the decimal places of the result to float to 2 places, i.e. 10.00 instead of 10 I found the toFixed function, but can't seem to use it properly... I'd appreciate any help. Thanks
window.onload = function() { var base = 3; document.getElementById('quantity').onkeyup = function() { if(this.value.length == 0) { document.getElementById('result').innerHTML = ''; return; } var number = parseInt(this.value); if(isNaN(number)) return; document.getElementById('result').innerHTML = number * base; }; document.getElementById('quantity').onkeyup(); };