Click to See Complete Forum and Search --> : variables not adding


javascripthelpB
10-26-2003, 11:38 AM
I'm trying to populate a total with two variables (tax and subtotal). When I display the total it shows tax and subtotal amounts but doesn't add them together.
Don't understand why.

function UpdateTotals(){
if (document.frmCustOrderInfo.country.value == "Canada"){
var listbox = document.frmCustOrderInfo.quantityAmount;
quantity = parseInt(listbox.options[listbox.selectedIndex].value);
subtotal = (quantity * price).toFixed(2);
tax = ((subtotal * GST) + (subtotal * PST)).toFixed(2);
total = ( subtotal + tax );
document.frmCustOrderInfo.txtPrice.value = subtotal
document.frmCustOrderInfo.txtTaxes.value = tax
document.frmCustOrderInfo.txtShipHand.value = shiphand.toFixed(2);
document.frmCustOrderInfo.txtTotal.value = total
}

Mr J
10-26-2003, 12:02 PM
Try this

total = ( subtotal*1) + (tax*1);

javascriptHelp
10-26-2003, 12:16 PM
Thanks so much!!!

Works Great!!!

Khalid Ali
10-26-2003, 12:23 PM
or
total = ( Number(subtotal) + Number(tax) );