If the following function performs calculation

<script type="text/javascript">
function updatesum() {
document.PaymentForm.newbalance.value = (document.PaymentForm.balance.value -0) - (document.PaymentForm.paymentamount.value -0);
}
</script>

How do I incorporate above function and the one below into one to thus do the calculation and round the number?

<script type = "text/javascript">

function roundNumber(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}

alert (roundNumber (12345.6789, 2));
</script>

Any thoughts!
Mossa

If the following function performs calculation

<script type="text/javascript">
function updatesum() {
document.PaymentForm.newbalance.value = (document.PaymentForm.balance.value -0) - (document.PaymentForm.paymentamount.value -0);
}
</script>

How do I incorporate above function and the one below into one to thus do the calculation and round the number?

<script type = "text/javascript">

function roundNumber(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}

alert (roundNumber (12345.6789, 2));
</script>

Any thoughts!
Mossa

Found answer:

<script type="text/javascript">
function updatesum() {
var bal = document.PaymentForm.balance.value - document.PaymentForm.paymentamount.value;
bal = Math.round(bal*Math.pow(10,2))/Math.pow(10,2);
document.PaymentForm.newbalance.value = bal;
}
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.