Removing specific tickboxes from a matrix question | XM Community
Skip to main content

Hi 

I have a survey with a couple of matrix questions where I need to hide specific options from respondents. For example, in the below picture I have 2 statements that only need apply to 4 scale points, and want to hide the cells highlighted in yellow.

For various legacy reasons I can’t separate these out into a different question, and I also can’t just route out respondents who select those options. Before I resort to the less-preferable option of using custom validation, is there a way using Javascript or CSS that I can hide specific boxes like this?

 

Thanks in advance!

 

Hi @Berotti ,

 

Please refer to this link (https://community.qualtrics.com/custom-code-12/hide-check-box-in-matrix-question-11889)

 

It should help.

 

Thanks,

JB


Thanks @Jagdish . I was able to tweak this to work on specific cells and copy the code over until all the cells I needed to hide were hidden. For those in future who come across this thread, the below example will hide the 5th box in the table, reading across from top left to bottom right:

Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" input:eq(5)").closest("td").find("*").hide();
});

However, this does not work with statement randomisation or display logic. Is there a way I could make this apply to specific boxes regardless of where they end up positioned? Perhaps using specific element IDs if those exist?

Thanks

B


To anyone who finds this thread in the future: I managed to solve my own problem by using ChatGPT to help me write the code. You can hide specific checkboxes in a matrix question by using a code like the one below:

Qualtrics.SurveyEngine.addOnload(function() {
// Remove checkboxes and labels
var elementsToRemove = [
"QR~QID5~1~4",
"QR~QID5~1~3",
"QR~QID5~2~4",
"QR~QID5~2~3"
];

elementsToRemove.forEach(function(elementId) {
var checkbox = $(elementId);
if (checkbox) {
var label = document.querySelector('label[for="' + elementId + '"]');
if (label) {
checkbox.parentNode.removeChild(checkbox);
label.parentNode.removeChild(label);
}
}
});
});

Switch out the “QR~QID5~1~4” etc. with your own unique identifiers, which you can find by previewing the survey, right clicking on the box you want to hide, and selecting “Inspect”.


Leave a Reply