Page counter | XM Community
Skip to main content
Question

Page counter

  • April 17, 2023
  • 2 replies
  • 437 views

Forum|alt.badge.img+8

Hi!

 

I want to add a page counter to a survey but it isn't working.

I have this css code

.PageNumber::before {
    content: "Page " counter(page) " of " counter(pages);
}

2 replies

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20

You can use embedded data to increment the count on every page load (if user click on next button) likewise if you have previous button then you can decrement the count and then use the embedded data as a pipe-text in the footer.


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 909 replies
  • April 18, 2023

Hi, following MohammedAli_Rajapkar’s recommendation, first create an Embedded Data element “n” at the top of the Survey Flow and set its value to 1. Then, add the below to the survey’s Header:

Page Number: <h class="counts"></h>
<script>
var n = parseInt("${e://Field/n}");
jQuery(".counts").html(n);

jQuery("#PreviousButton").click(function() {
Qualtrics.SurveyEngine.setEmbeddedData("n", n-1);
});

jQuery("#NextButton").click(function() {
Qualtrics.SurveyEngine.setEmbeddedData("n", n+1);
});
</script>