Skip to content

Instantly share code, notes, and snippets.

View marketinview's full-sized avatar

Market In View marketinview

View GitHub Profile
@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 / labelBipolarMatrixCols.js
Last active October 23, 2022 14:50
Qualtrics: Label Bipolar Matrix Columns. NOT for mobile. #qualtrics #js #jq #matrix #bipolar
Qualtrics.SurveyEngine.addOnload(function() {
var clh = jQuery("#"+this.questionId+" tr.ColumnLabelHeader");
clh.find("td:first").html("Statement A");
clh.append("<td class='yAxisBorder'></td><td>Statement B</td>");
});
@marketinview
marketinview / saveDisplayedMCChoicesAsEDs.js
Last active October 23, 2022 14:52
Qualtrics: Save MC Displayed Choices as Embedded Data Variables. #qualtrics #js #jq #mc #vars
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" label.SingleAnswer > span").each(function(i) {
Qualtrics.SurveyEngine.setEmbeddedData("item"+(i+1),jQuery(this).html());
});
this.clickNextButton();
});
@marketinview
marketinview / reverseMobileHorizontalMCChoices.js
Last active October 23, 2022 14:53
Qualtrics: Reverse Mobile Horizontal MC Choices. #qualtrics #js #jq #mc #horizontal #reverse
Qualtrics.SurveyEngine.addOnload(function() {
var row = jQuery("#"+this.questionId+" tr");
var cells = row.find("td");
if(cells.css("display") == "block") cells.each(function(i) { if(i > 0) row.prepend(jQuery(this)); });
});
@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 / Qualtrics_iOS13iPhoneSafariFix.js
Created January 17, 2020 20:05
Qualtrics: iOS13 iPhone Safari Fix - Fixes scrolling and powered by qualtrics click issue in iOS 13 Safari for iPhone. Place script in survey header. #qualtrics #js #jq #iphone #ios13 #safari #scroll
<script>
Qualtrics.SurveyEngine.addOnReady(function() {
jQuery("#Plug a").attr("href", "javascript:void(0)");
jQuery("#Plug a").click(function(e) { e.preventDefault(); });
setTimeout(function() { window.scrollTo(0,0); },200);
});
</script>
@marketinview
marketinview / moveMCtextBoxes.js
Last active October 23, 2022 14:59
Qualtrics: Move Multiple Choice Text Entry Boxes Inside Label. #qualtrics #js #jq #mc #text
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .TextEntryBox").each(function() {
var tb = jQuery(this);
tb.css({"float":"none","background-color":"white","width":"100%"});
tb.prev("label").css("display","block").append(" ").append(tb);
});
});
@marketinview
marketinview / reverseMobileMatrixChoices.js
Last active October 23, 2022 15:01
Qualtrics: Reverse Mobile Matrix Choices. Reverse the order of choices in a mobile (accordian) matrix question. Right to Left = Top to Bottom. #qualtrics #js #jq #matrix #mobile #scale #accordian #reverse
Qualtrics.SurveyEngine.addOnload(function() {
if(jQuery("#"+this.questionId+" .QuestionBody.mobile").length > 0) {
jQuery("#"+this.questionId+" tr.ChoiceRow").each(function() {
var label = jQuery(this).find("th");
jQuery(this).find("td").each(function(index) {
var choice = jQuery(this);
if(index > 0) {
label.after(choice);
if(choice.hasClass("last")) choice.removeClass("last");
}
@marketinview
marketinview / hideTextFormLabels.js
Last active October 23, 2022 15:02
Qualtrics: Hide Text Form Labels. #qualtrics #js #jq #text #form #hide #labels
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" td:not(.ControlContainer)").hide();
});
@marketinview
marketinview / answerOneChoiceMC.js
Last active October 23, 2022 15:03
Qualtrics: Automatically answer a multiple choice question with only one choice and go to next page. #qualtrics #js #jq #mc #carryforward
Qualtrics.SurveyEngine.addOnReady(function() {
var qobj = this;
var displayedChoices = [];
jQuery.each(qobj.getChoices(), function(index, value) {
if(qobj.getChoiceDisplayed(value)) displayedChoices.push(value);
});
if(displayedChoices.length == 1) {
qobj.setChoiceValue(displayedChoices[0], true);
qobj.clickNextButton();
}