How do you output a value using the Custom Calculation Script box?
Hi there,
I have a form and am trying to calculate a Total, but when I run the form, the field stays blank and my knowledge is limited. The javascript reads as follows:
Many thanks.
// First we need our array
arr = [
q1,
q2,
q3,
q4,
q5,
q6,
q7,
q8,
q9,
q10,
q11,
q12,
q13,
q14,
q15,
q16,
q17,
q18,
q19,
q20,
q21,
q22,
q23,
q24,
q25,
q26,
q27,
q28,
q29,
q30,
q31,
q32,
q33,
q34,
q35,
q36,
q37,
q38,
q39,
q40,
q41,
q42,
q43,
q44,
q45,
q46,
q47,
q48,
q49,
q50,
q51,
q52,
q53,
q54,
q55,
q56,
q57,
q58,
q59,
q60,
q61,
q62,
q63
];
// This variable will be our total score
var score = 0;
// This variable will be the number of valid good practice indicators
var countValid = 0;
// We iterate through all the answers and establish both the score and the number of valid good practice indicators
for (var i = 0; i < arr.length; i++) {
if (arr == 0 || arr == 1 || arr == 2) {
score = score + arr;
countValid++;
};
}
// Now we have our precentage completion figure
var percentCompletion = score / (2 * (countValid));
event.value = percentCompletion;
