Jay, I think you're right, that you need to account for whether the id is there or not. Using your code, here's what I would do (hope this is thorough enough)"
The code below has been changed. Basically if the row is on the page, then we add it to their respective variable. Finally we sum the variables of elements on the page. Let me know if I'm still missing the mark.
function calcSum() {
var var1 = 0;
var var2 = 0;
var var3 = 0;
var Sum = 0;
if ( document.getElementById("QS7_r1") ) {
var1 = Number(document.getElementById("QS7_r1").value);
}
if ( document.getElementById("QS7_r2") ) {
var2 = Number(document.getElementById("QS7_r2").value);
}
if ( document.getElementById("QS7_r3") ) {
var3 = Number(document.getElementById("QS7_r3").value);
}
Sum = var1 + var2 + var3;
document.getElementById("QS7_tot").value = Sum;
}