Show a specific statement missed in forced response | XM Community
Skip to main content
I'm trying to appease a client request to indicate the specific statement that was missed using a forced response in a Likert scale Matrix question that has 16 statements. As it shows now, if they miss one of the statements and try to proceed, a general message appears asking them to 'Answer all the questions on the page...'. With 16 requirements, it can be difficult to find the one that was missed. Is there a JS I could use to display the specific statement(s) that was missed?

!
Sorry- edited. My response was not correct and there is no delete
Paste the below code in the js(OnReady) of the matrix question



var n=jQuery("#"+this.questionId+" .ChoiceRow").length;

if(jQuery("#"+this.questionId+" .ValidationError").text()!=""){

for(var i=0;i<n;i++){

if(jQuery(".ChoiceRow:eq("+i+") td input[type='radio']:checked").length==0){

jQuery(".ChoiceRow:eq("+i+")").css("background","lightpink");

}

}



}
Great - thank you Shashi - this should solve my client's concern!
> @Shashi said:

> Paste the below code in the js(OnReady) of the matrix question

>

> var n=jQuery("#"+this.questionId+" .ChoiceRow").length;

> if(jQuery("#"+this.questionId+" .ValidationError").text()!=""){

> for(var i=0;i<n;i++){

> if(jQuery(".ChoiceRow:eq("+i+") td input[type='radio']:checked").length==0){

> jQuery(".ChoiceRow:eq("+i+")").css("background","lightpink");

> }

> }

>

> }



Thanks for the answer! But if I have more than one matrix in the section it only seems to work on the first one. Do you know how I could generalise it to work on all of them?



Many Thanks
> @viki said:

> Thanks for the answer! But if I have more than one matrix in the section it only seems to work on the first one. Do you know how I could generalise it to work on all of them?

>

> Many Thanks





Here is the updated code:



var n=jQuery("#"+this.questionId+" .ChoiceRow").length;

if(jQuery("#"+this.questionId+" .ValidationError").text()!=""){

for(var i=0;i<n;i++){

if(jQuery("#"+this.questionId+" .ChoiceRow:eq("+i+") td input[type='radio']:checked").length==0){

jQuery("#"+this.questionId+" .ChoiceRow:eq("+i+")").css("background","lightpink");

}

}

}
> @Shashi said:

> > @viki said:

> > Thanks for the answer! But if I have more than one matrix in the section it only seems to work on the first one. Do you know how I could generalise it to work on all of them?

> >

> > Many Thanks

>

>

> Here is the updated code:

>

> var n=jQuery("#"+this.questionId+" .ChoiceRow").length;

> if(jQuery("#"+this.questionId+" .ValidationError").text()!=""){

> for(var i=0;i<n;i++){

> if(jQuery("#"+this.questionId+" .ChoiceRow:eq("+i+") td input[type='radio']:checked").length==0){

> jQuery("#"+this.questionId+" .ChoiceRow:eq("+i+")").css("background","lightpink");

> }

> }

> }

>

>



This works great, thank you!
@Sashi is it possible to modify the code for a Text Entry Matrix Type?

Is there any way to get this code to work to highlight just individual statements/lines within the matrix question (as opposed to highlighting all statements, completed or not)? Thanks.


Hello, it is possible to modify the code so that it highlights unanswered statements within a matrix table with 'request response' selected rather than 'force response'? Thanks!


https://www.qualtrics.com/community/discussion/comment/32186#Comment_32186The following code should work for you:
let my_interval;
Qualtrics.SurveyEngine.addOnReady(function(){
    let attempt = 1;
    document.querySelector("#NextButton").onclick = function() {
        my_interval = setInterval(() => {
            err_msg = document.querySelector("#ErrorMessage");
            if (err_msg != null) {
                console.log("done");
                solver();
                clearInterval(my_interval);
            }
        }, 10);
        
    };
    that =  this;
    var n = jQuery("#"+this.questionId+" .ChoiceRow").length;
    function solver (){
        attempt++;
          for(var i=0;i              if(jQuery("#"+that.questionId+" .ChoiceRow:eq("+i+") td inputtype='radio']:checked").length==0){
                  jQuery("#"+that.questionId+" .ChoiceRow:eq("+i+")").css("background","lightpink");
              }
          } 
      }
      this.questionclick = function(){
      if(attempt>1){

        for(var i=0;i            if(jQuery("#"+that.questionId+" .ChoiceRow:eq("+i+") td inputtype='radio']:checked").length!=0){
                jQuery("#"+that.questionId+" .ChoiceRow:eq("+i+")").css("background","");
            }
        }


      }
    }
});


Qualtrics.SurveyEngine.addOnUnload(function() {
    clearInterval(my_interval);
});


https://www.qualtrics.com/community/discussion/comment/32400#Comment_32400Hey could you provide this exact code except for a "side by side" instead of a matrix table?? that would be so great!


Have you tried this code? It should work for SBS also.


https://community.qualtrics.com/XMcommunity/discussion/comment/32400#Comment_32400Hi ahmedA , is there any other code for a slider question? I have tried to use this code for a slider question but it doesn't work.
Thank you very much.


I wonder if there is a method to do this with the Form question type?


This was great, but I’m using statement groups and if one selection is not made in one statement group, it highlights are the statement group headers. Any modification for this, please and thank you?!


This was great, but I’m using statement groups and if one selection is not made in one statement group, it highlights are the statement group headers. Any modification for this, please and thank you?!

You might be interested in the matrixHighlightUnanswered function. It has much more functionality than the code above, including compatibility with statement groups.


Leave a Reply