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

Show Open Text Box only when Other is selected


Forum|alt.badge.img+2

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?

Best answer by Tom_1842

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+" [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();
    }

  });

 

View original

3 replies

Sachin Nandikol
QPN Level 6 ●●●●●●
Forum|alt.badge.img+34
  • QPN Level 6 ●●●●●●
  • 463 replies
  • May 16, 2024

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.


Forum|alt.badge.img+2
  • Author
  • Level 1 ●
  • 11 replies
  • May 16, 2024

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.


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 876 replies
  • Answer
  • May 16, 2024

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+" [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();
    }

  });

 


Leave a Reply