Conditionally show Text box | XM Community
Skip to main content

For single or multi select question, we can add a text entry to any radio button.
is there is a way to hide it and only show it if the associated button is selected?

image.png

Paste the below code in the JS of the single choice question:
 var QID= this.questionId;
   jQuery("#" + QID + " .InputText ").hide();
 jQuery("#" + QID + " .Selection ").on("click change",function(){

    jQuery("#" + QID + " input+type='radio']").each(function(){

      if(jQuery(this).prop("checked") == true)
      {
          var v1 = jQuery(this).attr("id");
        jQuery("aid*='"+v1+"~TEXT']").show();
        }
      else
      {
      var v1 = jQuery(this).attr("id");
      jQuery("rid*='"+v1+"~TEXT']").val('');
      jQuery("bid*='"+v1+"~TEXT']").hide();
     }    
   });
   });
For multi choice selection, just change word - 'radio' to 'checkbox' in the above code


https://www.qualtrics.com/community/discussion/comment/27093#Comment_27093Hey rondev I tried running this on "on ready" and "on load" event however it dont work. Am I missing something?


Leave a Reply