Show a specific statement missed in forced response | XM Community
Skip to main content
Solved

Show a specific statement missed in forced response


TheLeadershipFactor
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? !

Best answer by Anonymous

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"); } } }
View original

16 replies

Forum|alt.badge.img+19
  • Level 5 ●●●●●
  • 543 replies
  • February 14, 2019
Sorry- edited. My response was not correct and there is no delete

  • 0 replies
  • Answer
  • February 14, 2019
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"); } } }

TheLeadershipFactor
Great - thank you Shashi - this should solve my client's concern!

  • 2 replies
  • February 22, 2019
> @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

  • 0 replies
  • February 22, 2019
> @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"); } } }

  • 2 replies
  • February 22, 2019
> @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!

  • 2 replies
  • August 7, 2019
@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.


  • 2 replies
  • December 2, 2020

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!


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • December 8, 2020

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 input[type='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 input[type='radio']:checked").length!=0){
                jQuery("#"+that.questionId+" .ChoiceRow:eq("+i+")").css("background","");
            }
        }


      }
    }
});


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


  • 2 replies
  • May 5, 2021

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!


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • May 6, 2021

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


Forum|alt.badge.img+1
  • 2 replies
  • December 23, 2021

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.


Forum|alt.badge.img+4
  • Level 1 ●
  • 3 replies
  • September 28, 2022

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


Forum|alt.badge.img+3
  • 6 replies
  • June 19, 2023

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?!


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5937 replies
  • June 19, 2023
Paola wrote:

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