Dynamically select checkbox

Could you explain to me how I get the number of check boxes? and how would I select the different checkboxes? without the loop checking and unchecking the same checkbox?
thank you friend