multiple choice -> text entry (hidden) | XM Community
Skip to main content
Solved

multiple choice -> text entry (hidden)

  • May 28, 2019
  • 5 replies
  • 19 views

Forum|alt.badge.img+3
How to achieve the beginning of the text entry is hidden, the text entry appears when the other option is selected,like this. !! thanks a lot.

Best answer by elf

Hi @Cathaya, Use the below code to achieve this. Place the script in Qualtrics.SurveyEngine.addOnReady() jQuery('input:text').hide(); var rid =jQuery("input[type='text']").parent().parent().find("input[type='radio']").attr("id"); jQuery("[type='radio']").change(function() { if(jQuery("[id='"+rid+"']").prop("checked") == true) { jQuery("[id*='"+rid+"~TEXT']").show(); } else { jQuery("[id='"+rid+"~TEXT']").val(''); jQuery("[id='"+rid+"~TEXT']").hide(); } });

5 replies

Forum|alt.badge.img+4
  • QPN Level 2 ●●
  • Answer
  • May 28, 2019
Hi @Cathaya, Use the below code to achieve this. Place the script in Qualtrics.SurveyEngine.addOnReady() jQuery('input:text').hide(); var rid =jQuery("input[type='text']").parent().parent().find("input[type='radio']").attr("id"); jQuery("[type='radio']").change(function() { if(jQuery("[id='"+rid+"']").prop("checked") == true) { jQuery("[id*='"+rid+"~TEXT']").show(); } else { jQuery("[id='"+rid+"~TEXT']").val(''); jQuery("[id='"+rid+"~TEXT']").hide(); } });

Forum|alt.badge.img+5
  • Level 3 ●●●
  • May 28, 2019
@Alfia, I would also love to do this, but the code doesn't appear to be doing anything when placed into the AddOnReady section. Any ideas how to fix it? EDIT: It worked under the "OnLoad"

Forum|alt.badge.img+4
  • QPN Level 2 ●●
  • May 28, 2019
> @uhrxx005 said: > @Alfia, I would also love to do this, but the code doesn't appear to be doing anything when placed into the AddOnReady section. Any ideas how to fix it? Thanks, I've updated the code, please check..

Forum|alt.badge.img+5
  • Level 3 ●●●
  • May 28, 2019
What changed? I actually got it working fine when I moved it to the OnLoad instead of OnReady section

Forum|alt.badge.img+1
  • August 15, 2019
Hi! This helped me, but only works with the small sized text entry. How can it work with a medium size text entry too?