Sum up fields in a matrix table

cflasrado18cflasrado18 Boca RatonCommunity Member Qubie ✭
edited October 2019 in Custom Code

Sum up fields in a matrix table

I want to auto calculate some fields from the matrix table below:

I know the only way to do this would be by using JavaScript so I tried the below but it is not working:

function setQuestionString(number, str){
var question = document.getElementById("QR~QID" + number);

    question.value = str;
}

var registration_total = "${q://QID9/ChoiceTextEntryValue/1/1}";
var reg_total = parseInt(registration_total, 10);
var registration_a = "${q://QID9/ChoiceTextEntryValue/1/2}";
var a = parseInt(registration_a, 10);
var registration_b = "${q://QID9/ChoiceTextEntryValue/1/3}";
var b = parseInt(registration_b, 10);
var registration_c = "${q://QID9/ChoiceTextEntryValue/1/4}";
var c = parseInt(registration_c, 10);
var i= 0;

reg_total = a + b + c;

registration_total = reg_total.toString();
while (i<12){
setQuestionString(9, "registration_total");

}

Best Answer

Sign In to Comment