Script: Override Progress Percentage

This article will help you add code to a override the progress bar percentage calculation if needed


Background

You may need to override the 'Progress Bar' calculation. This will show you how to do so. 


Instructions

  1. Access the 'Build & Edit' Tool
  2. Access the 'Default Text' 
  3. Click on the HTML Editor icon tied to the 'Survey Header' 
  4. Access the Source Code Editor (</>)
  5. While in the Source Code Editor, add the following code
    1. Update the 'modifyBeforePage' from 41 to the last page number of your survey you want this calculation to be modified
    2. Update the 'maxPercentage' from 12 to whatever you want the max percentage to be 
      <script>
      var modifyBeforePage = 41;
      var maxPercentage = 12;
      cmSurvey.onLoad(function()
      {
      var pageNum = parseInt(jQuery('.cm-pageWrapper').attr('id').replace('page-', ''), 10);
      if (pageNum < modifyBeforePage)
      {
      var newPercentage = ((pageNum * maxPercentage) / modifyBeforePage);
      newPercentage = Math.floor(newPercentage);
      jQuery('.cm-progress-bar-text').text(newPercentage + '% Complete');
      }
      });
      </script>
      		

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.