Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Question number order mixes up

We are using a code that shows the number of the question in the left top corner with using the code:


if (window.performance) {
  console.info("window.performance works fine on this browser");

var x = Number(getCookie("questionNo"));

if ((performance.navigation.type != 1) && (x < 65)) {
    console.info( "This page is not reloaded" );
    x = x + 1;

document.cookie = "questionNo=" + x + "; expires=Mon, 31 Dec 2021 12:00:00 UTC";

function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i <ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
    return "";

of 65)

The problem here is, the order of the questions are not showing properly; we start seeing (65 of 65) even at the beginning of the quesiton block.  And also I would like to add that this code works properly (i guess) from time to time but at the very last question, which is the 65th, the order label repeats itself as (65 of 65), (65 of 65), (65 of 65) for 4-5 times. Do you know how to solve this?

Thanks a lot in advance!

asked Apr 8 by CaEr (450 points)
edited Apr 8 by CaEr
Cookies persist.  So if you run Test Survey over and over again on the same browser, each test respondent will start with the same starting point as the previous test respondent.  You'd need to reset the cookie to 0 or 1 or whatever on the first page to change that behavior.

I don't know what you mean when you say the label repeats itself on the last question.  How are you continuing to a next page multiple times when already past the last question?  Is this question looped?

Regardless, you may want to consider using the PageNumber function instead of using cookies:

[% PageNumber() %]
incredible! thanks a lot zachary <3 We set chrome not to get cookies from our survey link so everything is fine :)

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.