​​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.

  1. Open the form in design mode.
  2. Add the following to the form design workspace:
    How to retrieve the counts of checked boxes in a CheckBoxList control.jpg
  3. Select TextBox1 and switch the "Number Only" property to ON.
  4. Select Checkboxlist1 control.
  5. In the Rules pane, click on the Add icon to add a new rule, the Rule Manager dialog will open.
    How to auto-shifting Panel control in a form2.jpg
  6. 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:
    1. In case the "Number Only" property is set to ON, type this script:
      var array=getCheckBoxListItems(Checkboxlist1) setValue(Textbox1,array.length)
    2. 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.
  7. Test the form by clicking on the Preview button in the View Group.