How do I hide a row in a matrix table using JavaScript based on the label of the row? | XM Community
Skip to main content

I'm trying to hide certain rows based on embedded data and the label of the row. Basically, if the label of a row is equal to one of the embedded data fields, then I'd like to hide this row (see this question for more context; I'm trying to solve this problem by setting choices from previous questions as embedded data).
I'm trying to build this out slowly as I'm new to Javascript, and I'm stumped on how to iterate through rows and hide them based on labels. To figure out the hiding step, I built a simple matrix table with 'Lemon', 'Apple', and 'Orange' as rows, and I'd like to hide the row if the label says 'Lemon'. This doesn't hide anything however. Any help would be greatly appreciated! Thanks in advance.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
for (let i = 1; i < 4; i++) {
var row = jQuery("#"+this.questionId+"~"+i);
if (row.text() == 'Lemon') {
row.closest('tr').hide();
};
};
});


Be the first to reply!

Leave a Reply