4 Replies Latest reply on Aug 8, 2013 7:55 AM by vshanker

Counting Check Boxes with values

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?

• 1. Re: Counting Check Boxes with values

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.

• 2. Re: Counting Check Boxes with values

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.

• 3. Re: Counting Check Boxes with values

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.

• 4. Re: Counting Check Boxes with values

Hello,

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

if(CheckBox1.rawValue == true)

TextFeild1.rawValue = 1;