/    Sign up×
Community /Pin to ProfileBookmark

variables not adding

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
}

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JOct 26.2003 — Try this

total = ( subtotal*1) + (tax*1);
Copy linkTweet thisAlerts:
@javascriptHelpOct 26.2003 — Thanks so much!!!

Works Great!!!
Copy linkTweet thisAlerts:
@Khalid_AliOct 26.2003 — or

total = ( Number(subtotal) + Number(tax) );
×

Success!

Help @javascripthelpB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...