Skip to content

Instantly share code, notes, and snippets.

View marketinview's full-sized avatar

Market In View marketinview

View GitHub Profile
@marketinview
marketinview / addSymbolBeforeAfterText.js
Last active April 29, 2024 11:13
Qualtrics: Add Symbol or Text Before and/or after Open End Text entry. #qualtrics #js #jq #text
Qualtrics.SurveyEngine.addOnload(function() {
var input = jQuery("#"+this.questionId+" .InputText");
input.before("$ ");
input.after(" /mo");
input.select().focus(); //optional, focus on input field
});
@marketinview
marketinview / carouselExclusive.html
Last active March 6, 2024 16:02
Qualtrics: Carousel Exclusive Scale Points. Make scale point exclusive by placing its label inside an element with class "exclusive". #qualtrics #js #jq #carousel #exclusive
<span class="exclusive">Scale Point Label</span>
@marketinview
marketinview / choicesToList.js
Last active February 6, 2024 16:10
Qualtrics: MC choices to list. Use to present an unordered (bullets) or ordered (numbered) randomized list of items. #qualtrics #js #jq #random #list #bullets #numbered
Qualtrics.SurveyEngine.addOnload(function() {
var listType = "ul"; //use ul for unorderd list, ol for ordered list
var q = jQuery(this.questionContainer);
q.find(".QuestionBody").hide();
q.find(".QuestionText").append("<"+listType+" class='choiceList'></"+listType+">");
var list = q.find(".choiceList").css("margin-bottom","0px");
q.find("label.SingleAnswer>span").each(function() { list.append("<li>"+this.innerHTML+"</li>"); });
});
@marketinview
marketinview / displayTextInputWordCount.js
Last active November 27, 2023 17:57
Qualtrics: Display count of words in a text entry box. Option to limit number of words. #qualtrics #js #jq #text #count #word #limit
Qualtrics.SurveyEngine.addOnload(function() {
var maxWords = 0; //update as needed, 0=no limit
var q = jQuery("#"+this.questionId);
var input = q.find(".InputText");
input.after("<div style='font-size:0.8em;float:right'>Word count: <span class='wordCount'>0</span><span class='maxWords'></span></div>");
var display = q.find(".wordCount");
if(maxWords > 0) q.find('.maxWords').text("/"+maxWords);
countWords(input.get(0));
input.on("input", function() { countWords(this) });
input.blur(function() { this.value = this.value.trim(); });
@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 / likertScaleVertical.html
Last active September 28, 2023 13:39
Qualtrics: Likert Scales Vertical #qualtrics #css #matrix #likert #scale #vertical #answers
<style>
.Skin .Matrix table tr.ChoiceRow td {
display:block;text-align:left;padding:5px 2px;border-left:1px solid #666;border-right:1px solid #666; }
.Skin .Matrix table th.c1 { border-left:1px solid #666;border-bottom:1px solid #666; }
.Skin .Matrix table tr.ChoiceRow td:last-of-type { border-bottom:1px solid #666; }
.Skin .Matrix table tr.ChoiceRow:first-of-type th,
.Skin .Matrix table tr.ChoiceRow:first-of-type td:first-of-type { border-top:1px solid #666; }
.JFEScope .Skin .desktop .mobile { display: inline!important; }
tr.Answers { display:none; }
.JFEScope .Skin .desktop .mobile.dropdown-arrow { display:none!important; }
@marketinview
marketinview / adjustCSInputTextWidths.js
Last active September 11, 2023 05:55
Qualtrics: Adjust Constant Sum Input Text Widths. Change "75px" as needed. #qualtrics #js #jq #csum #input #text #width
Qualtrics.SurveyEngine.addOnload(function() {
var inputWidth = "75px";
var q = jQuery("#"+this.questionId);
q.find('.SumInput').css("width", inputWidth);
q.find('.SumTotal').css("width", inputWidth);
q.find('.InputText').css("width", inputWidth);
});
@marketinview
marketinview / ageFromDOB.header.html
Created August 28, 2023 15:01
Qualtrics: Age from Date of Birth #qualtrics #js #jq #age #birthdate #dob #luxon
<script src="https://cdn.jsdelivr.net/npm/luxon@3.4/build/global/luxon.min.js"></script>
@marketinview
marketinview / mcSelectLanguage.css
Last active August 27, 2023 14:33
Qualtrics: Select Language with Multiple Choice. Hides the language drop down selector and has the respondent pick language in a Multiple Choice question. Specify language codes in choice html. #qualtrics #js #jq #mc #language #translate
.LanguageSelectorContainer, span.langCode { display:none; }
@marketinview
marketinview / qualtrics.array.from.polyfill.js
Created August 25, 2023 14:04
Qualtrics: Replace Qualtrics Array.from Polyfill with one that supports iterables #qualtrics #js #polyfill #array #from
Qualtrics.SurveyEngine.addOnload(function() {
console.log(Array.from({length: 20}, (e, i) => i));
});
// Production steps of ECMA-262, Edition 6, 22.1.2.1
// Copied and modified from http://www.devdoc.net/web/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from.html
Array.from = (function () {
var toStr = Object.prototype.toString;
var isCallable = function (fn) {
return typeof fn === 'function' || toStr.call(fn) === '[object Function]';