Hello,
I have a matrix question with 3 statements (A, B, C) and 2 scale points (yes and no). I am trying to write a code such that B will show up when A is yes, and C will show up when B is yes. If no is chosen, respondents will be auto advanced to the next question.
All suggestions, and/or examples are very much appreciated!
Thanks in advance, and have a nice day!
Solved
Logic display and auto advance on a matrix question
Best answer by ahmedA
No, it's my fault for not looking into the nitty-gritties. This should do the job for you:
Qualtrics.SurveyEngine.addOnReady(function () {
all_rows = this.getQuestionContainer().querySelectorAll("tr");
that = this;
for (var i = 2; i < all_rows.length; i++) {
all_rows[i].hide();
}
this.questionclick = function (ev, el) {
var row = Number(el.id.split("~")[2]);
var choice = Number(el.id.split("~")[3]);
if (choice == 2 || row == all_rows.length - 1) {
that.clickNextButton();
} else if (choice == 1) {
all_rows[row + 1].show();
}
};
});
You can remove
|| row ==all_rows.length-1if you do not want to auto advance when a Yes on the third row is clicked.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
