Multiple choice question with text - how to only show text if that choice is selected? | XM Community
Skip to main content
Solved

Multiple choice question with text - how to only show text if that choice is selected?

  • February 15, 2019
  • 5 replies
  • 529 views

dlively
Level 1 ●
Forum|alt.badge.img+2
I have a multiple choice question with 7 choices. Five of the choices have a text box for additional information. I would like for the text and text box to show only IF that option is selected. How do I go about creating this, preferably within Qualtrics without java. Thank you, Donna

Best answer by TomG

> @dlively said: > Tom, I got this to work with the JavaScript below. The only problem is that the check boxes no longer appear in Preview. Can you help me with this? That is because the theme you are using doesn't show check boxes; it has nothing to do with the JS. You can change the theme under Look & Feel. Alternatively, you can add text like "Please select all that apply" to your question text.

5 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 16, 2019
It can only be done with JavaScript.

dlively
Level 1 ●
Forum|alt.badge.img+2
  • Author
  • Level 1 ●
  • February 18, 2019
Tom, I got this to work with the JavaScript below. The only problem is that the check boxes no longer appear in Preview. Can you help me with this? Donna Lively PREVIEW ! DESIGN VIEW ! JavaScript Qualtrics.SurveyEngine.addOnload(function() { /*Place your JavaScript here to run when the page loads*/ }); Qualtrics.SurveyEngine.addOnReady(function() { var QID= this.questionId; jQuery("#" + QID + " .InputText ").hide(); jQuery("#" + QID + " input[type='checkbox']").each(function(){ if(jQuery(this).prop("checked") == true) { var v1 = jQuery(this).attr("id"); jQuery("[id*='"+v1+"~TEXT']").show(); } else { var v1 = jQuery(this).attr("id"); jQuery("[id*='"+v1+"~TEXT']").val(''); jQuery("[id*='"+v1+"~TEXT']").hide(); } }); jQuery("#" + QID + " .Selection ").on("click change",function(){ jQuery("#" + QID + " input[type='checkbox']").each(function(){ if(jQuery(this).prop("checked") == true) { var v1 = jQuery(this).attr("id"); jQuery("[id*='"+v1+"~TEXT']").show(); } else { var v1 = jQuery(this).attr("id"); jQuery("[id*='"+v1+"~TEXT']").val(''); jQuery("[id*='"+v1+"~TEXT']").hide(); } }); }); }); Qualtrics.SurveyEngine.addOnUnload(function() { /*Place your JavaScript here to run when the page is unloaded*/ });

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • February 18, 2019
> @dlively said: > Tom, I got this to work with the JavaScript below. The only problem is that the check boxes no longer appear in Preview. Can you help me with this? That is because the theme you are using doesn't show check boxes; it has nothing to do with the JS. You can change the theme under Look & Feel. Alternatively, you can add text like "Please select all that apply" to your question text.

dlively
Level 1 ●
Forum|alt.badge.img+2
  • Author
  • Level 1 ●
  • February 18, 2019
Thank you very much for your assistance. Donna

  • November 17, 2019
@TomG @dlively I tried implementing the JavaScript as you did Donna. It does not work for me. I will include my code below for review. --- Qualtrics.SurveyEngine.addOnload(function() { /*Place your JavaScript here to run when the page loads*/ }); Qualtrics.SurveyEngine.addOnReady(function() { var QID= this.questionId; jQuery("#" + QID + " .InputText ").hide(); jQuery("#" + QID + " input[type='checkbox']").each(function(){ if(jQuery(this).prop("checked") == true) { var v1 = jQuery(this).attr("id"); jQuery("[id*='"+v1+"~TEXT']").show(); } else { var v1 = jQuery(this).attr("id"); jQuery("[id*='"+v1+"~TEXT']").val(''); jQuery("[id*='"+v1+"~TEXT']").hide(); } }); jQuery("#" + QID + " .Selection ").on("click change",function(){ jQuery("#" + QID + " input[type='checkbox']").each(function(){ if(jQuery(this).prop("checked") == true) { var v1 = jQuery(this).attr("id"); jQuery("[id*='"+v1+"~TEXT']").show(); } else { var v1 = jQuery(this).attr("id"); jQuery("[id*='"+v1+"~TEXT']").val(''); jQuery("[id*='"+v1+"~TEXT']").hide(); } }); }); }); Qualtrics.SurveyEngine.addOnUnload(function() { /*Place your JavaScript here to run when the page is unloaded*/ });