Expand my Community achievements bar.

Counting Check Boxes with values

Avatar

Level 1

I have a sub-form where I gave each check box a value: sum(ICB6, ICB7, ICB11, ICB12, ICB16, ICB17, ICB21, ICB22), but what I want to do now is take this total and divide by the # of check boxes actaully checked. For example; if 2 of the boxes are checked my total is 7, then I want to divide it by 2 (the number of boxes checked) to get 3.5 as my score. I can not figure out how to make that happen?

4 Replies

Avatar

Level 9

If we assume that the Default value of your unchecked checkbox is zero, in the click/change event of the checkbox you can total the value of the checkboxes and divide it by 2.

Var total = (CheckBox1.rawValue + CheckBox2.rawValue+ CheckBox3.rawValue + ....) / 2

Thanks,

Bibhu.

Avatar

Level 1

Thanks for replying, but I do not always want it to divide by 2, that was just an example.  I want it to divide by however many check boxes might be checked.  So it could be 2 it could be 7 just depending on what is checked. 

Avatar

Level 9

Well, then in that case you can use another variable for dividing instead of 2.

Lets say var divider. Then set the value, then divide.

Thanks,

Bibhu.

Avatar

Former Community Member

Hello,

You can have one hidden text feild and increase the rawValue as per check box selection.

if(CheckBox1.rawValue == true)

TextFeild1.rawValue = 1;