show / hide menu

How to find selected check-box in a check-box group

How to find selected check-box in a check-box group:

Step 1 : Create a form with a check-box group ,two text-boxes, one  button as shown in figure 1.

Figure 1

Step 2 : On text-box ‘txtJS’ give the default value as  

return  $(“input[type=’checkbox’] :checked”,$ (“#CheckBoxGrpID”)). length;

Figure 2

Step 3:Write the following three actions on the ‘Get Count’ button as the trigger.

Figure 3
  • txtJS.Value=StringReplace(txtJS.Value,”CheckBoxGrpID”,GetControlId(chkgroup))

You can change ‘chkgroup’ with your checkbox group name.

  • txtResult.Value=ExecuteJavaScript(txtJS.Value)

After executing javascript the result will be shown in the textbox ‘txtResult’.

  • txtJS.Value=StringReplace(txtJS.Value,GetControlId(chkgroup),”CheckBoxGrpID”)

You can change ‘chkgroup’ to your checkbox group name.

Preview :

Figure 4

Select the items in the check-box group and click on ‘Get Count’ button then the count of selected check-boxes will be shown in the text-box ‘txtResult’.