Hi Everyone,
I'm constructing a survey and encountering a problem with hiding questions.
Quick run through of the situation: The first question asks respondents to select 1 or more characteristics of a product that can be improved. Each of the answers (if selected) has 3 additional questions that should be shown. For each answer not selected, those 3 additional questions belonging to the answer should be hidden and record the default choices.
After reading through many of the questions in the community, I think I need to hide questions using JavaScript so that the response will set as the default choice that it's set to.
I've tried using display logic and it will not keep the default choices because the question isn't displayed. I've tried using embedded data but I need the default choices as the response due to exporting purposes.
I attempted to use code similar to below, but it wouldn't work if multiple answers were selected. I would appreciate any help.
Qualtrics.SurveyEngine.addOnload(function() {
if("${q://QID1/SelectedChoicesRecode}"!="2") jQuery("#"+this.questionId).hide();
});
Thanks!
Solved
How can I hide a questions that aren't selected from a multiple choice multiple answer question?
Best answer by TomG
You need to hide the question then loop through the selected choices and show the question if "2" is selected.
Qualtrics.SurveyEngine.addOnload(function() {
var q = jQuery("#"+this.questionId).hide();
jQuery.each("${q://QID1/SelectedChoicesRecode}".split(", "),function(i,val){
if(val == "2") { q.show(); return; }
});
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.