Matrix Likert Answers Count Validation across multiple questions | XM Community
Skip to main content
Solved

Matrix Likert Answers Count Validation across multiple questions

  • April 21, 2023
  • 2 replies
  • 77 views

MikeW
Level 5 ●●●●●
Forum|alt.badge.img+14
  • Level 5 ●●●●●

I have a 5 Matrix Likert Multiple Answers questions on one page. I’d like respondents to click on at least 8 points in total across the 5 questions before they proceed.

 

I did find some JS in another post that counts the answers on one question (and that disables the next button until they click enough answers), but not sure how to adjust that to check across the 5 questions…

Qualtrics.SurveyEngine.addOnReady(function(){
that = this;
var init_ques = this.getQuestionTextContainer().innerText;
this.disableNextButton();
this.questionclick = function () {
var a = that.getSelectedAnswers();
var ch = Object.values(a).reduce(function (a, b) {
return a + b;
},0);
if(ch >=3){
that.enableNextButton();
that.getQuestionTextContainer().innerText = "Okay to proceed";
} else {
that.disableNextButton();
that.getQuestionTextContainer().innerText = init_ques;
}
}
});

 

Best answer by Shashi

Use the below code in any one of the Matrix question

Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
this.disableNextButton();
jQuery(".Matrix").find("input[type='checkbox']").on('change',function(){
if(jQuery(".Matrix").find("input[type='checkbox']:checked").length>=8)
that.enableNextButton();
else
that.disableNextButton();
});
});

 

2 replies

Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+34
  • Level 8 ●●●●●●●●
  • Answer
  • April 21, 2023

Use the below code in any one of the Matrix question

Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
this.disableNextButton();
jQuery(".Matrix").find("input[type='checkbox']").on('change',function(){
if(jQuery(".Matrix").find("input[type='checkbox']:checked").length>=8)
that.enableNextButton();
else
that.disableNextButton();
});
});

 


MikeW
Level 5 ●●●●●
Forum|alt.badge.img+14
  • Author
  • Level 5 ●●●●●
  • April 21, 2023

Use the below code in any one of the Matrix question

Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
this.disableNextButton();
jQuery(".Matrix").find("input[type='checkbox']").on('change',function(){
if(jQuery(".Matrix").find("input[type='checkbox']:checked").length>=8)
that.enableNextButton();
else
that.disableNextButton();
});
});

 

Perfect. Thank you!