Copy link to clipboard
Copied
These check boxes have hidden values (1-5) and we would like to calculate the the average of these values only if those particular Check Boxes are checked. The Check Boxes in each row are named the same. Thanks for any help you can provide!
So, the checkboxes in each row are mutually exclusive? And these hidden values are actually the exports for the checkboxes?
I would add a group name to the existing checkbox name. Assuming the names of the check box rows are "CkRow1" "CkRow2" etc. then the grouped names would be "Grp.CkRow1" "Grp.CkRow2" etc.
This code placed in the calculation script for a text field will produce the average.
var aChecks = this.getField("Grp").getArray();
var sum = 0;
aChecks.forEach(function(a){sum+=a.value;});
e
...Copy link to clipboard
Copied
You must add an if-condition checking if cnt is zero, because division by zero is not allowed.
Replace the last line with this:
if (cnt==0) event.value = "";
else event.value = sum/cnt;
Copy link to clipboard
Copied
fixed it in my post
Copy link to clipboard
Copied
Oh my gosh, that did the trick! Thank you for being so patient with me, and helping me so much Thom!! You Rock 😄