How to remove "N/A" options for some sub questions (statements) in a matrix question | XM Community
Skip to main content
Solved

How to remove "N/A" options for some sub questions (statements) in a matrix question


Forum|alt.badge.img+1

Hi,
I have a question in my survey which contains five sub questions. I am finding a way to remove the “Not applicable” option for sub-questions 3 to 5 (see the picture attached). Could anyone teach me how to do that. Is that possible or I have to split this question into two?
image.png
Many thanks for your help!


Best answer by ahmedA

Qualtrics.SurveyEngine.addOnReady(function () {
    let qc = this.questionContainer;
    let all_na = qc.querySelectorAll(".last");
    all_na[3].hide();
});
Add this code to your js.
The

.last
refers to the last column of your matrix.
Now
all_na 
will contain all the cells of your last column.
You can hide them one by one, just repeat the last line for all the rows you want to hide.

View original

8 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • Answer
  • June 14, 2021

Qualtrics.SurveyEngine.addOnReady(function () {
    let qc = this.questionContainer;
    let all_na = qc.querySelectorAll(".last");
    all_na[3].hide();
});
Add this code to your js.
The

.last
refers to the last column of your matrix.
Now
all_na 
will contain all the cells of your last column.
You can hide them one by one, just repeat the last line for all the rows you want to hide.


Forum|alt.badge.img+1

Hi AhmedA,
Thank you very much it works perfectly well! :)
Regards,
Houston



Forum|alt.badge.img+1

Thanks for this good answer.

I wonder how can I select not just the last column to hide, but all columns save the first column?


Forum|alt.badge.img+1

In my case the N/A is the last row, not a column. That's because I need n/a as a question item for the user to indicate the entire question is not relevant for them. I therefore want to hide the answer columns for the n/a row, except for one column (the columns are frequency, so it doesn't make sense to fill out a frequency for the n/a item in my case).
I managed to hide multiple columns this way:
Qualtrics.SurveyEngine.addOnReady(function () {
  let qc = this.questionContainer;
 // console.log(this.getQuestionInfo());
var all_na = new Array();
var columns = [".c4", ".c5", ".c6", ".c7"] 
for (let i = 0; i < columns.length; i++) {
  qc.querySelectorAll(columns[i])[10].hide();
  };
});

However now the n/a question item no longer works as an exclusive item. Any idea why?


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • 1549 replies
  • November 6, 2022

https://community.qualtrics.com/XMcommunity/discussion/comment/51815#Comment_51815elephantus
Don't use the hide function use the below style property. It will keep the exclusive property intact. You can change the column id's as needed.
 qc.querySelectorAll(columns[i])[10].style.visibility="hidden";
Hope it helps!


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5929 replies
  • November 6, 2022

elephantus ,
In the last row, hide all but last column (regardless of number of rows or columns):
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .ChoiceRow").last().find("td").not(".last").find("*").hide();
});


Forum|alt.badge.img+1

https://community.qualtrics.com/XMcommunity/discussion/comment/51818#Comment_51818Thank you Deepak! That indeed works. What is frustrating is that the behaviour of exclusivity is for the same column only - and not for all columns. So in other words, I would like it when a specific answer choice is chosen, that it deletes any other choices made in other options across all columns in the matrix.

Thank you


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • 1549 replies
  • November 7, 2022

Leave a Reply