Hi,
I have downloaded a javascript that is just about perfect for my project. The only thing it doesn’t do….I have tried hard to make it do this….is to give the result with two decimal places. For example, if I add (say) 21.20 and 21.20, the answer is 42.4 but I really want it to say 42.40. I have been experimenting with ‘toFixed(2)’ but I can’t get this to work. Can anyone help me please? Many thanks.
Here is the code….
<script type=”text/javascript”>
function startCalc(){
interval = setInterval(“calc()”,1);
}
function calc(){
one = document.autoSumForm.firstBox.value;
two = document.autoSumForm.secondBox.value;
document.autoSumForm.thirdBox.value = (one * 1) + (two
}
function stopCalc(){
clearInterval(interval);
}
// End –>
</script>
</HEAD>
<BODY>
<form name=”autoSumForm”>
<input type=text name=”firstBox” value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> +
<input type=text name=”secondBox” value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> =
<input type=text name=”thirdBox”>
</form>