There's a lot of repetitive code, so I won't include it all, but the main jist of it is here:
var Qs1;
var Qs2;
var Qs3;
var Qs4;
var Qs5;
var Qs6;
var Qs7;
var Qs8;
var Qs9;
var Qs10;
if(boilingPan25 == 0) {
var Qs1 = nBP * QBP * Zi0;
} else if(boilingPan25 == 1) {
var Qs1 = nBP * QBP * Zi1;
} else if(boilingPan25 == 2) {
var Qs1 = nBP * QBP * Zi2;
} else if(boilingPan25 == 3) {
var Qs1 = nBP * QBP * Zi3;
} else if(boilingPan25 == 4) {
var Qs1 = nBP * QBP * Zi4;
} else {
var Qs1 = 5 * QBP * Zi5;
}
//document.write(Qs1);
if(tiltingPan70 == 0) {
var Qs2 = nTP * QTP * Zi0;
} else if(tiltingPan70 == 1) {
var Qs2 = nTP * QTP * Zi1;
} else if(tiltingPan70 == 2) {
var Qs2 = nTP * QTP * Zi2;
} else if(tiltingPan70 == 3) {
var Qs2 = nTP * QTP * Zi3;
} else if(tiltingPan70 == 4) {
var Qs2 = nTP * QTP * Zi4;
} else {
var Qs2 = 5 * QTP * Zi5;
}
So the values of the variables Qs1 ... Qs10 are found through the if loops. When I go to add all of these values together, it prints out a concatenation of the numbers, rather than simply adding them. Here's how I'm printing it out:
document.write(Qs1 + Qs2 + Qs3 + Qs4 + Qs5 + Qs6 + Qs7 + Qs8 + Qs9 + Qs10);
I've tried adding ".value" to the ends of each variable, but that doesn't work. Any suggestions? Please with Javascript only, no jQuery. Thanks.