Skip to main content
Participant
August 6, 2024
Answered

Total of chosen check boxes

  • August 6, 2024
  • 1 reply
  • 603 views

hi,

 

looking for some help. Total beginner here!

I'm creating a learning styles questionnaire, where the user will have statements to "check" if it applies to them. 
After reading and checking the statements, the user is presented with a "scoring" where they are shown 4 columns with the numbers relating to each statement. They have to go back through and mark off the statements they checked, which will then indicate which column has the most checked statements, and therefore, their learning style. 

I have added check boxes next to each statement. But now, I'm hoping to make the results section easier than them having to scroll back and forth to mark what they checked. Is there a way to automate their responses e.g. if they check statement 39, 55, 60 and 62 it will automatically pick this up and know there are 4 checked answers in the "reflector" learning style. 

I've uploaded an image of how it looks currently. 

thanks!

This topic has been closed for replies.
Correct answer try67

Sure, that's possible with a script.

Say the fields are named "CB1", "CB2", etc., but you only want to count the number of checked check-boxes from some of them. Since there doesn't seem to be a mathematical logic to it, you would need to define those fields in an array, then iterate over that array and count how many are checked.

For example, you can use this code as the custom Calculation script of the first total field (note I didn't enter all the field names. You'll have to fill them out yourself):

 

 

var fields = ["CB2", "CB4", "CB6", "CB10", "CB17"]; // fill in with rest of the field names for this category
var totalChecked = 0;
for (var i in fields) {
	var f = this.getField(fields[i]);
	if (f.valueAsString!="Off") totalChecked++;
}
event.value = totalChecked;

 

 

Repeat the same code (with different field names, of course) for the other columns, and you're done!

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 6, 2024

Sure, that's possible with a script.

Say the fields are named "CB1", "CB2", etc., but you only want to count the number of checked check-boxes from some of them. Since there doesn't seem to be a mathematical logic to it, you would need to define those fields in an array, then iterate over that array and count how many are checked.

For example, you can use this code as the custom Calculation script of the first total field (note I didn't enter all the field names. You'll have to fill them out yourself):

 

 

var fields = ["CB2", "CB4", "CB6", "CB10", "CB17"]; // fill in with rest of the field names for this category
var totalChecked = 0;
for (var i in fields) {
	var f = this.getField(fields[i]);
	if (f.valueAsString!="Off") totalChecked++;
}
event.value = totalChecked;

 

 

Repeat the same code (with different field names, of course) for the other columns, and you're done!

Participant
August 6, 2024

Thank you so much! This worked a treat