Show/Hide Matrix Text Entry Boxes Based on Specific Options | XM Community
Skip to main content
Question

Show/Hide Matrix Text Entry Boxes Based on Specific Options

  • August 13, 2025
  • 3 replies
  • 51 views

Forum|alt.badge.img+8

Hi everyone,

I have a matrix-type question in Qualtrics where each row has a set of radio button options (Extremamente satisfeito, Satisfeito, Neutro, Insatisfeito, Nada satisfeito), and also an open text box directly under the row label.

What I’m trying to do is:

  • Keep all the text boxes hidden by default.

  • Show the text box only when the respondent selects “Insatisfeito” or “Nada satisfeito” (columns 1 or 2 from the left in my case).

  • If the respondent changes their selection to something else, hide the text box again and clear its value.

I’ve tried some JavaScript in the “AddOnload” section, but the text boxes still appear when the page loads or don’t hide/show reliably. I suspect it’s because Qualtrics renders these inputs in a <th> tag and they’re visible before my script runs.

Here’s my current code attempt (not working as expected):
 

Qualtrics.SurveyEngine.addOnload(function () {
    var qid = this.getQuestionInfo().QuestionID;

    jQuery("#" + qid + " .TextEntryBox").css("display", "none");

    function updateTextBoxes() {
        jQuery("#" + qid + " tbody tr").each(function () {
            var $row = jQuery(this);
            var $selected = $row.find("input[type=radio]:checked");
            var $textBox = $row.find(".TextEntryBox");

            if ($selected.length > 0) {
                var colClass = $selected.closest("td").attr("class") || "";
                if (colClass.includes("c7") || colClass.includes("c8")) {
                    $textBox.show();
                } else {
                    $textBox.hide().val("");
                }
            } else {
                $textBox.hide().val("");
            }
        });
    }

    updateTextBoxes();

    jQuery("#" + qid + " input[type=radio]").on("change", updateTextBoxes);
});


Has anyone solved something similar?

3 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • August 14, 2025

Try this:

Qualtrics.SurveyEngine.addOnload(function() {
var q = jQuery(this.getQuestionContainer());
q.find(".TextEntryBox").hide();
var radios = q.find("input[type=radio]");
radios.filter(":checked").each(function() { //support back button
if(this.value=="4" || this.value=="5") jQuery(this).closest("tr").find(".TextEntryBox").show();
});
radios.click(function() {
var text = jQuery(this).closest("tr").find(".TextEntryBox");
if(this.value=="4" || this.value=="5") text.show();
else text.val("").hide();
});
});

 


Forum|alt.badge.img+8
  • Author
  • QPN Level 4 ●●●●
  • August 14, 2025

they still display the text box not sure if it is related with the layout. I am using the new qualtrics layout.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • August 15, 2025

Yes, it is the layout. Based on the element types and class names in your post it appeared you were not using New Experience.

For New Experience, you can use the same logic flow as I did above with some adjustments, but it is more complicated.