this is my code:
$(function() {
$('input[name^=sum]').keyup(function() {
var sum0 = parseFloat($('input[name=sum0]').val()) || 0;
var sum1 = parseFloat($('input[name=sum1]').val()) || 0;
$('#act_rate').val(sum1/sum0);
});
});
This little script calculates the actual exchange rate from 2 input fields. I would like to display the act_rate with no more than 8 decimal places like 1.12345678. How can I format the outcome like that?
Many thanks for your help in advance.
Peter
Use the toFixed() method.
Or, if you want 8 decimal places or less:
http://jsfiddle.net/mblase75/WNXSA/