Multiplying and Adding Numbers:

The example:

Price

Enter Quantity

We'll create a function that will format the numbers correctly.

function format(val,currency) {
val=(val+"").replace(/\,/g,"");
return ((currency? currency:"") +
(Math.round(val*100)+
(val<0?-0.1:+0.1))/ 100).replace(/(.*\.\d\d)\d*/,'$1');
}

Invoking the function:

<input type="button" name="Button" value="Calculate" onclick="total.value=format(price.value*qty.value,'$')">

More Maths.-