Skip to content

Instantly share code, notes, and snippets.

View marketinview's full-sized avatar

Market In View marketinview

View GitHub Profile
@marketinview
marketinview / changeNpsScale.js
Last active October 31, 2023 12:47
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
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');
@marketinview
marketinview / hidePreviousButton.js
Last active October 23, 2022 17:06
Qualtrics: Hide Previous Button. Sometimes a previous button will not work properly. In those cases it is better to hide the previous button using the following script. This script can be used in a question or in the header if you want it to apply to the entire survey. #qualtrics #js #jq #button #previous #hide
Qualtrics.SurveyEngine.addOnReady(function() {
jQuery('#PreviousButton').hide();
});
@marketinview
marketinview / hideQuestionGoToNextPage.js
Last active October 23, 2022 17:05
Qualtrics: Hide Question and Go To Next Page. This script can be used if you want to randomize choices then carry them over in the same randomized order to subsequent questions. #qualtrics #js #jq #hide #next
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId).hide();
jQuery("#Buttons").hide();
});
Qualtrics.SurveyEngine.addOnReady(function() {
jQuery('#NextButton').click();
});
@marketinview
marketinview / hideQuestionText.js
Last active October 23, 2022 17:03
Qualtrics: Hide Question Text. On occasion, it is useful to hide a question's text and just display the choices/answers. #qualtrics #js #jq #hide #questiontext
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .QuestionText:first").parent().hide();
});
@marketinview
marketinview / matrixVerticalLineBeforeLastColumn.js
Last active October 23, 2022 17:00
Qualtrics: Add Vertical Line Before Last Matrix Column. This script adds a vertical line to the left of the last column in a matrix question. It is useful for visually dividing an answer scale from "Not sure". #qualtrics #js #jq #matrix #na
Qualtrics.SurveyEngine.addOnload(function() {
var q = jQuery("#"+this.questionId);
var cl = q.find('td.ColumnLabels:first');
if(cl.length > 0) cl.attr('colspan', cl.attr('colspan') - 1);
if(q.find('div.desktop').length > 0) q.find('.last').css("border-left", "1px solid #BBBBBB");
});
@marketinview
marketinview / add2ndLabelColumnToMatrix.css
Last active October 23, 2022 16:54
Qualtrics: Two Column Matrix Labels. Use the following CSS to change Matrix row labels into two columns. The optional JavaScript can be used to label the columns. #qualtrics #css #js #jq #matrix #label #column
<style type="text/css">
.wrap {
width:300px;
margin:0 auto;
float:left;
}
.left_col {
float:left;
width:240px;
text-align:left;
@marketinview
marketinview / changeNextButtonText.js
Last active October 23, 2022 16:57
Qualtrics: Change Next Button Text. This script changes the text of the Next button. Change value of newName value as needed. #qualtrics #js #jq #next #button #finish
Qualtrics.SurveyEngine.addOnReady(function() {
var newName = 'Finish'; //Update - New Next Button label
var lastLoopOnly = true; //Last loop only? Value doesn't matter to non-loops
//No changes below
if(!lastLoopOnly || "${lm://CurrentLoopNumber}" == "${lm://TotalLoops}") {
var nb = jQuery('#NextButton');
nb.val(newName);
nb.attr('title', newName);
}
});
@marketinview
marketinview / limitCharactersMCTextEntry.js
Last active October 23, 2022 16:55
Qualtrics: Limit Characters in a Multiple Choice Text Entry Box. Unlike a text entry question, an "allow text entry" box that is part of a multiple choice question does not have a built-in option to limit the number of characters in the response. The following script adds that functionality by adding the maxlength attribute to the html <input> t…
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .InputText").attr("maxlength", "100");
});
@marketinview
marketinview / changeTextInputToReadOnly.js
Last active October 23, 2022 16:57
Qualtrics: Change Text Input Field to Read Only. This script changes a text input field to read only (a side-by-side question in this example). This could be used if you want to display a default value in a field, but don’t want it to be changed. #qualtrics #js #jq #text #readonly
Qualtrics.SurveyEngine.addOnload(function() {
var qid = this.questionId;
jQuery(('#QR~'+qid+'#1~1~1~TEXT').replace(/~/g, "\\~")).attr("readonly", "readonly");
}
@marketinview
marketinview / sumSingleMatrixColumn.js
Last active October 23, 2022 16:56
Qualtrics: Sum a Single Matrix Column. The last row in the Matrix question is a Total. In this example, the third input column (c6) is the one that is totaled and must add to 100. The totals for the first two input columns (c4 and c5) are hidden. The total is a readonly field so the respondent can't change it. The only other thing to do is add a…
Qualtrics.SurveyEngine.addOnload(function() {
var q = jQuery("#"+this.questionId);
q.find('td.c4:last input').hide();
q.find('td.c5:last input').hide();
var totalInput = q.find('td.c6:last input');
totalInput.prop("readonly", true);
totalInput.css("font-weight", "bold");
var sumInputs = q.find('td.c6:not(:last) input');
sumInputs.on("keyup", function(event) {
sumCol();