Script: Grid Checkboxes - Display Total Checkboxes Selected

This article will help you display the total number of selected Checkboxes in a Grid 


Background

You may have scenarios in which you have a Grid setup with Checkboxes and you want to display how many have been selected. This article will show you how.  


Instructions

  1. Program your 'Grid' question with Checkboxes in either orientation
  2.  Add the following code to the '</> Add Javascript' field
    • See article: Adding JavaScript and/or CSS to a Question
    • Line 2 is where you can update the Total Text as needed
      var $ = jQuery,
      totalText = "Total Selected = ", /* TOTAL TEXT TO BE UPDATED */
      total = $("input[type='checkbox']:checked").length,
      footer = $(".cm-instructions:last");
      
      footer.text(totalText + total);
      
      $("input[type='checkbox']").change(function(){
      total = $("input[type='checkbox']:checked").length;
      footer.text(totalText + total);
      });
      		
  3. For the code to work you need to:
    1. Click on the '+ Footnote' button. 
    2. Add any character to the field. 
      • NOTE: Anything you add in this field will be replaced by the total. 
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.