NPS question | XM Community
Skip to main content

Good morning,

I have a question in nps which goes from 0 to 10 in my question 1 "Q1". I created a second question without using display logic so that if I put in q1 between 0 to 6 it displays me in a paragraph "sorry", 7 to 8 "good" and 9 to 10 "very good " with js code but it's the first time I'm using it and I'm a little lost. Thank you very much for your help.

Sincerely

You could create three different questions with display logic for each where if 0-6 is selected, it displays “sorry,” if 7-8 is selected, it displays “good.”


Thank you for your response. Yes I know that but I wondered if I just could do with one question and add a condition with JavaScript.


Good morning,

I have a question in nps which goes from 0 to 10 in my question 1 "Q1". I created a second question without using display logic so that if I put in q1 between 0 to 6 it displays me in a paragraph "sorry", 7 to 8 "good" and 9 to 10 "very good " with js code but it's the first time I'm using it and I'm a little lost. Thank you very much for your help.

Sincerely

  1. Add this to your 2nd question text richcontent editor → source
    div id="messageDisplay"></div>

     

  2. Add this JS to the 2nd question
    Qualtrics.SurveyEngine.addOnload(function() {
    var npsScore = parseInt("${q://QID1/ChoiceGroup/SelectedChoices}");
    var message = "";

    if (npsScore >= 0 && npsScore <= 6) {
    message = "Sorry";
    } else if (npsScore >= 7 && npsScore <= 8) {
    message = "Good";
    } else if (npsScore >= 9 && npsScore <= 10) {
    message = "Very Good";
    }

    var messageElement = document.getElementById("messageDisplay");
    if (messageElement) {
    messageElement.innerHTML = message;
    }
    });

    Note: I’m assuming Id of Q1 is QID1 so please check if ${q://QID1/ChoiceGroup/SelectedChoices} pull out the correct Q1 value and change it if necessary.

Hope this helps


Thank you so much, this really help me.


Thank you so much, this really help me.

Happy to help 👍


Leave a Reply