How can I make my text entry box only appear when I click on the option that has the text entry | XM Community
Question

How can I make my text entry box only appear when I click on the option that has the text entry

  • 14 June 2021
  • 1 reply
  • 190 views

Userlevel 2
Badge +1

Hi,



I am trying to hide the text entry box for my answers with the text entry box unless you click on it. I have found these two codes for multiple answer type questions and single answer type questions but none of them are working. See below:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
jQuery('input:text').hide();
  jQuery("[type='checkbox']").change(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*/

});

jQuery('input:text').hide();
this.questionclick = function(event,element)
  {    
    if (element.type == 'radio')
    {
      jQuery('input:text').val('').hide();
   jQuery("[id*='"+ element.id+"~TEXT']").show();
       
    }
  }


1 reply

Userlevel 7
Badge +22

The multiple answer type questions code is working correct, please recheck if you are pasting it correctly.

Leave a Reply