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

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

  • 14 June 2021
  • 8 replies
  • 168 views

Userlevel 2
Badge +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!


icon

Best answer by ahmedA 14 June 2021, 03:18

View original

8 replies

Userlevel 7
Badge +21

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.

Userlevel 2
Badge +1

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


Badge +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?

Badge +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?

Userlevel 7
Badge +35

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!

Userlevel 7
Badge +27

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();
});

Badge +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

Userlevel 7
Badge +35

https://community.qualtrics.com/XMcommunity/discussion/comment/51830#Comment_51830elephantus You can implement click function on the below code for just the last row options and use the code mentioned in this link to reset all radio button.
Qualtrics: Reset Likert Matrix. Works with single or multi-select matrix. Add button html to question text. #qualtrics #js #jq #matrix #likert #reset · GitHub
Hope it helps!

Leave a Reply