Help with Custom Progress Bar | XM Community
Skip to main content
Question

Help with Custom Progress Bar

  • January 18, 2025
  • 8 replies
  • 110 views

Forum|alt.badge.img+1
  • Level 1 ●
  • 7 replies

Hi everyone,

I’m trying to manually control the progress bar in my survey to update at specific points (e.g., after certain key questions) rather than relying on Qualtrics’ default logic. My goal is to dynamically update the progress bar percentage and ensure it retains my custom settings across the survey.

I’ve come across several posts and solutions, including Change value of the progress bar. From there, I used the following code:

jQuery("div.ProgressBarFill").css("width", assignedProgress + "%");

This works initially for the specific questions where I add it, but as soon as I move to the next question, the progress bar reverts to Qualtrics' default logic. Since my survey has many questions, applying this code to every single one isn’t practical.

Is there an easier way to dynamically override the progress bar logic throughout the survey, ensuring that the progress bar retains the custom percentage from the previous update until the next custom update is applied?

Thank you in advance for your help!

8 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • January 19, 2025

When you make changes using jQuery, you are basically just changing things in the browser, nothing on the server. Hence, even after you update the progress bar to your desired value, the server doesn’t know or care about it. Therefore, you get the server’s default value on each page.

Your only option is to specify the progress bar value for each page, you don’t need to do it for each question, just each page. 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • January 19, 2025

Thank you for your response, ​@ahmedA ! I realize now that I mistakenly referred to "questions" instead of "pages" in my original post. In my survey, each question needs to be displayed on a separate page.

From your explanation, I understand that there's no shortcut for this, and I'll need to include the code on each individual page. I appreciate your help!


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5919 replies
  • January 20, 2025

@M414,

You can include your code in either the header or footer inside a <script> tag and it will apply to every page.  Also, you could turn off the Qualtrics progress bar add your own using the <progress> tag.


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • January 20, 2025

Thanks ​@TomG, I will give it a try.


AlonsoC
Administrator
Forum|alt.badge.img+12
  • Administrator
  • 208 replies
  • January 21, 2025

Hi ​@M414, did the solution offered fix your issue?


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • January 21, 2025

Hi ​@AlonsoC  and ​@TomG, I tried to add the following code to the Footer in Look & Feel but it does not work as intended. Any suggestions you might have on this? Thanks a lot!

 

<div id="customProgressContainer" style="position: relative; width: 100%; background-color: #e0e0e0; height: 10px; margin-top: 20px;">
  <progress id="customProgressBar" value="0" max="100" style="width: 100%; height: 100%;"></progress>
</div>

<script>
  Qualtrics.SurveyEngine.addOnload(function () {
    let progressMap = {
      "QID1": 10,  // Page 1 = 10%
      "QID2": 50,  // Page 2 = 50%
      "QID3": 100  // Page 3 = 100%
    };

    let currentQuestionID = this.getQuestionInfo().QuestionID;

    if (progressMap[currentQuestionID] !== undefined) {
      document.getElementById("customProgressBar").value = progressMap[currentQuestionID];
    }
  });
</script>
 


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5919 replies
  • January 21, 2025

@M414,

When you run a script from the header or footer the question object ‘this’ is undefined. You can get the first QuestionID on a page like this:

var qid = Object.keys(Qualtrics.SurveyEngine.QuestionInfo)[0];

 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • January 21, 2025

Thanks ​@TomG, I could not make it work yet but I am working on it. Appreciate the help!


Leave a Reply