How to retrieve the counts of checked boxes in a CheckBoxList control?
Last Update: January 25, 2018
Here are the steps on how to retrieve the counts of checked boxes in a CheckBoxList control.
- Open the form in
design mode.
- Add the following to the form design workspace:

- Select TextBox1 and switch the "Number Only" property to ON.
- Select Checkboxlist1 control.
- In the
Rules pane, click on the Add icon to add a new rule, the
Rule Manager dialog will open.
- Add a new rule as follows:
A. Change the
Rule Name as desired.
B. Change the
Rule Type to Action.
C. Change the
Event Type to onChange. Leave "Execute if event triggered only on this control" unchecked.
D. In the
Action section, type the following script:
- In case the "Number Only" property is set to ON, type this script:
var array=getCheckBoxListItems(Checkboxlist1) setValue(Textbox1,array.length) - In case the "Number Only" property is OFF, type this script:
var array=getCheckBoxListItems(Checkboxlist1) setValue(Textbox1,(array.length).toString())
//If Textbox1 is string ("Number Only" property is set to OFF) and no item in the Checkboxlist1 is checked, the system will not be able to evaluate Zero and the value of Textbox1 value will be 1, therefore and to get the correct result, we convert the array length to string.
E. Click on the
Save button to save the rule.
Note: You can use
Assistance Panel to help you adding functions and related parameters, form variables and form controls to
Conditions and/or
Actions sections. - Test the form by clicking on the
Preview button in the
View Group.