Skip to content

Instantly share code, notes, and snippets.

@marketinview
Last active October 23, 2022 15:11
Show Gist options
  • Save marketinview/a42e22ccd4244fad03c1e2c9ca17d065 to your computer and use it in GitHub Desktop.
Save marketinview/a42e22ccd4244fad03c1e2c9ca17d065 to your computer and use it in GitHub Desktop.
Qualtrics: Hide/Show Next Question Based On Drop-Down. #qualtrics #js #jq #dropdown #select #hide #show #next
Qualtrics.SurveyEngine.addOnload(function () {
//Hide or show next question based on drop down (select)
var q = jQuery("#"+this.questionId);
var next = q.nextAll('.Separator:first, .QuestionOuter:first'); //next separator & question
var select = q.find('select:first'); //select element
hideShow(select.get(0)); //initialize to support prev button
select.on('change', function() { hideShow(this); });
function hideShow(selEl) {
var selIdx;
(selEl.selectedIndex < 0) ? selIdx = 0 : selIdx = selEl.selectedIndex;
var selText = selEl.options[selIdx].text;
if (selText == 'Others' || selText == '') next.hide();
else next.show();
selEl.blur();
}
});
@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