Show Open Text Box only when Other is selected | XM Community
Skip to main content

Hi champs,

 

I have the below question where “others” appears 3rd in the list and would like to show the text box only when respondent selects others.

What would be the best way to achieve this?

Hello @R_cstalin

I suggest following these steps:

  1. Move the 'Others' option to the last choice.
  2. Add a new question (Text Entry question) and set the display logic to show if 'Others' is selected. Choose the 'In-Page' option.
  3. Remove the question text for the Text Entry question, and use CSS code to eliminate the white space between the two questions.

Let me know if this helps.


Thanks for replying Sachin.

Due to some scenario of grouping, we need to keep the others option above in the list and can’t fix that at the end.

Also, if we move it to another question, it would still look like it’s a different question.

We are looking for a option to show it there itself.


I’ve used this in the past to show the text input when the checkbox is selected and to hide when unselected. Try adding the below to the question’s JavaScript in the OnReady section:

var qid = this.questionId;

jQuery('#'+qid+' input:text').hide();

jQuery("#"+qid+" dtype='checkbox']").change(function(){

if(jQuery(this).prop("checked") == true){
var v1 = jQuery(this).attr("id");
jQuery("rid*='"+v1+"~TEXT']").show();
}else{
var v1 = jQuery(this).attr("id");
jQuery("rid*='"+v1+"~TEXT']").val('');
jQuery("rid*='"+v1+"~TEXT']").hide();
}

});

 


Leave a Reply