Hide text boxed in multiple answer questions | XM Community
Skip to main content

Hide text boxed in multiple answer questions

  • September 20, 2022
  • 3 replies
  • 368 views

Forum|alt.badge.img+8

Hi!
I have a question that has multiple answers that have the option to allow text entry.
i'd like to hide the all text boxes until the customer selects the option.
Screen Shot 2022-09-20 at 14.02.10.pngQualtrics.SurveyEngine.addOnReady(function () {

  var text_box = this.getChoiceContainer().querySelector(".TextEntryBox");
  text_box.hide();

  this.questionclick = function () {
    var text_choice = text_box.ancestors()[1].children[1].className.includes("checked");
    if (text_choice) {
      text_box.show();
    } else {
      text_box.hide();
    }
  };
});

I have this one but it just works to hide one text box out of the 4.

3 replies

Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • September 20, 2022

Hi there, I found a thread that I think will be helpful to you. In that, JavaScript is provided for doing what you are describing with Multiselect questions.
https://community.qualtrics.com/XMcommunity/discussion/3462/text-entry-box-only-shows-if-selected-in-multiple-choice-question


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • September 20, 2022

If you are interested, I have a more robust function called mcTextEntry that can be used for hiding text boxes of unselected choices. I works on single select or multi-select and does a lot of things to improve the look & feel of text entry fields in addition to hiding text them.


Forum|alt.badge.img+8
  • Author
  • QPN Level 4 ●●●●
  • September 21, 2022

Thank you guys!!