Skip to content

Instantly share code, notes, and snippets.

@marketinview
Last active May 31, 2024 11:56
Show Gist options
  • Save marketinview/c941fc59b7ddaef8ba3b to your computer and use it in GitHub Desktop.
Save marketinview/c941fc59b7ddaef8ba3b to your computer and use it in GitHub Desktop.
Qualtrics: Change NPS Scale. This script changes the scale of an NPS question from 0-10 to a smaller scale. 1-10 is most common, but any scale can be specified. For numbered horizontal scales, the NPS question type is preferable to a horizontal multiple choice because it remains horizontal on small screen mobile devices. #qualtrics #js #jq #nps …
Qualtrics.SurveyEngine.addOnload(function() {
//Thomas Gibbons Consulting
//Change NPS question scale (not simple layout)
var scaleStart = 1; //Change - 0 or more and no greater than end
var scaleEnd = 10; //Change - 10 or less and no less than start
//No changes below
var width = 100/(scaleEnd - scaleStart + 1) + "%";
var q = jQuery("#"+this.questionId);
var cc = q.find('td.ControlContainer');
q.find('td.LabelContainer').each(function(index) {
if(index<scaleStart || index>scaleEnd) {
this.hide();
cc[index].hide();
}
else {
this.setAttribute('width', width);
cc[index].style.width = width;
}
});
});
Qualtrics.SurveyEngine.addOnload(function() {
//Thomas Gibbons Consulting
//Change NPS question scale (simple layout)
var scaleStart=1, scaleEnd=10; //Change as needed
//No changes below
var q=jQuery(this.getQuestionContainer());
q.find(".choice").each(function(i) { if(i<scaleStart || i>scaleEnd) jQuery(this).hide(); });
});
@marketinview
Copy link
Author

Instructions:

  1. Add JavaScript to question.
  2. Set scaleStart and scaleEnd to desired values.

@marketinview
Copy link
Author

marketinview commented Nov 14, 2017

See additional Qualtrics solutions at: https://qualtricswiki.tgibbons.com/doku.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment