codice:
<form name="base">
<input name="op1" value="0" type="text" onblur="mul(this.form.op1.value, this.form.op2.value, this.form.ans);" /> *
<input name="op2" value="0" type="text" onblur="mul(this.form.op1.value, this.form.op2.value, this.form.ans);" /> =
<input name="ans" value="0" type="text" />
<input type="button" value=" [moltiplica] " onclick="mul(this.form.op1.value, this.form.op2.value, this.form.ans);" />
</form>
<script type="text/javascript">
<!--
function mul (source1, source2, answer)
{
source1 = parseFloat(source1);
source2 = parseFloat(source2);
if (!answer || isNaN(source1) || isNaN(source2))
return;
answer.value = Math.round (source1*source2*100) / 100;
}
//-->
</script>