Skip to content

Instantly share code, notes, and snippets.

Qualtrics.SurveyEngine.addOnload(function() {
jQuery(document).keydown(function (event) {
if (event.keyCode === 9) {
event.preventDefault();
return false;
}
});
});
Qualtrics.SurveyEngine.addOnload(function() {
var qid = '#' + this.questionId;
var words = ['i', 'love', 'hate', 'swimming', 'is', 'what', 'better'];
function init() {
showOptions(); // rmeove this if you want to just add the options manually in the question
jQuery(qid + ' input[type="text"]').blur(function() {
jQuery(qid + ' .ValidationError').hide();
if (textIsValid(jQuery(this).val())) {
jQuery('#NextButton').attr('disabled', false);
Qualtrics.SurveyEngine.addOnload(function() {
jQuery('#' + this.questionId).hide();
});
var hiddenQuestionId = 'QID8';
Qualtrics.SurveyEngine.addOnload(function () {
this.questionclick = function(event,element) {
if (element.type == 'radio') {
// save the winner as Embedded Data
var el = document.getElementById(element.id);
var parent = el.parentElement;
var img = parent.querySelector('span img');
Qualtrics.SurveyEngine.addOnload(function () {
this.questionclick = function(event,element) {
if (element.type == 'radio') {
var el = document.getElementById(element.id);
var parent = el.parentElement;
var img = parent.querySelector('span img');
Qualtrics.SurveyEngine.setEmbeddedData('Winner', img.id);
}
}
});
var imgId = '#Falcon';
var width = jQuery(imgId).width();
var scaleFactor = '${e://Field/scaleFactor}';
var newWidth = width * scaleFactor;
jQuery(imgId).width(newWidth);
Qualtrics.SurveyEngine.addOnload(function() {
var regex = /(my text string)|(my other text string)/gi;
var fieldName = 'FieldName';
// add listener to text boxes
jQuery('#' + this.questionId + ' textarea').on('blur', function() {
// Find the value typed in textbox
var value = jQuery(this).val();
if (value.match(regex)) {
Qualtrics.SurveyEngine.addOnload(function() {
// may need to modify these
var pickGroupQID = 'QID5'; // this is the qid of the Pick, Group, and Rank question
var numberOfGroups = 3; // how many groups do you have?
// add listeners to text boxes
for (var i = 1; i < numberOfGroups + 1; i++) {
var selector1 = '#' + this.questionId + ' .ChoiceStructure table tr:nth-child(' + i + ') input';
// store the group number for recall within event handler
Qualtrics.SurveyEngine.addOnReady(function() {
// Hide the real next button and the second question. You may need to swap out the QID on that
jQuery('#NextButton').hide();
jQuery('#QID2').hide();
// adding next button. To add styling, you could put some CSS in the Look and Feel targetting
// #FakeNextButton {}
jQuery('#Buttons').append('<button id="FakeNextButton">Next</button>');
Qualtrics.SurveyEngine.addOnload(function() {
// Qualtrics.SurveyEngine.setEmbeddedData('${q://QID18/ChoiceNumericEntryValue/3}', 67); // impossible
var x =34;
document.getElementById("demo1").innerHTML = x;
});