Drew012
07-06-2012, 03:25 AM
I have a list of questions. For each of them the user inputs a number from 0 - 100. The sum of the three numbers needs to be assigned as a variable. I am going to use that variable in a basic HTML chart where a plugin can change it.
So my question is from this code:
else if (countId == "Q5" || countId == "Q13" || countId == "Q21") {
var nFinancial = 0.0;
nFinancial = parseInt(document.getElementById("Q5").value);
nFinancial += parseInt(document.getElementById("Q13").value);
nFinancial += parseInt(document.getElementById("Q21").value);
tallyTable.rows[0].cells[4].firstChild.data = nFinancial;
}
As you can see for this block which is contained in a bigger funtion contains three question (Q5, Q13, and Q21). It functions properly but I need the result as a variable. This is not my code and I thought that nFinancial was the var that represented Q5+Q13+21. However, when I try to alert() the nFinancial var it does nothing when it should default at 0.0.
Thanks for your time, I can post more of the code if needed but this section was the one giving me the problems.
So my question is from this code:
else if (countId == "Q5" || countId == "Q13" || countId == "Q21") {
var nFinancial = 0.0;
nFinancial = parseInt(document.getElementById("Q5").value);
nFinancial += parseInt(document.getElementById("Q13").value);
nFinancial += parseInt(document.getElementById("Q21").value);
tallyTable.rows[0].cells[4].firstChild.data = nFinancial;
}
As you can see for this block which is contained in a bigger funtion contains three question (Q5, Q13, and Q21). It functions properly but I need the result as a variable. This is not my code and I thought that nFinancial was the var that represented Q5+Q13+21. However, when I try to alert() the nFinancial var it does nothing when it should default at 0.0.
Thanks for your time, I can post more of the code if needed but this section was the one giving me the problems.