adding a question counter within specific block | XM Community
Skip to main content

Hey,

I've tried different solutions offered here about the topic, none worked so far. 

For my survey, I need to put some sort of index that shows the participants how many questions in the block have been presented so far out of the total (for example: question 10/45). It needs to be visible throughout answering the block. The question block itself is randomized, and with a graphics question in each page.

I have tried using embedded data (perheps wrong? Since it did not work in preview).

also I thought maybe it's possible to alter the progress bar in 'looks and feel'. If it can be added to some of the blocks but not to the whole survey, and maybe if it's possible to change the text? 

Any idea would be much appreciated!

I have zero to very little knowledge in code, but I'm willing to learn if the solution requires it.

Thanks,

Mia

Hi @Miae12 ,

Hie believe you can implement that using JS and embedded Data :

Create an embedded data count and sets it value to 1 just before that block in survey flow.

Now, on each question in that block add below JS:

Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
let nextButton = document.getElementById('NextButton');


nextButton.addEventListener("click", function()
{

let count = parseInt(Qualtrics.SurveyEngine.getEmbeddedData('count'));


count += 1;


Qualtrics.SurveyEngine.setEmbeddedData('count', count);


console.log('Count value: ' + count);



});

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/

});

 And in text part you can show as below:
 

In preview it will show as below:
 


Hope this resolves your query😊!!
 


You can also hardcode the value for the counter… Since, you will have to show the counter on each page so above the question text of a particular page you can put page 1 out of 6, for page 2 you can put page 2 out of 6. 


Leave a Reply