How do I highlight rows in a matrix table if not selected? | XM Community
Solved

How do I highlight rows in a matrix table if not selected?

  • 23 July 2018
  • 9 replies
  • 175 views

Userlevel 2
Badge +2
Hi everyone,

I have a matrix question and if I miss to answer a row, I am getting an error message saying 'Please answer this question'.
Is there a way of highlighting the row that I have missed. Like in my screenshot below Currently it is very hard to identify the row that I have missed to answer.

Thank you.
Kai


!
icon

Best answer by Samarth 24 July 2018, 14:00

View original

9 replies

Userlevel 4
Badge +5
Hi @Kai,

I do similar thing by highlighting the missed rows.

!

Please place below CSS code in question text:

<style type="text/css">.redhighlight{
background-color:red!important;
}
</style>

and Below javascript code in java script tab:

Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

setInterval(function(){
jQuery('#NextButton').click(function(){
jQuery('.ChoiceStructure tr:nth-child(n+1)').not('.Answers').each(function(){
if(jQuery(this).find(":radio").is(':checked')==false){
jQuery(this).addClass('redhighlight');
localStorage.clear();
localStorage.setItem("clicked", "Yes");
}
else{
jQuery(this).removeClass('redhighlight');
}
});

});


if(localStorage.getItem("clicked") == "Yes"){
jQuery('.ChoiceStructure tr:nth-child(n+1)').not('.Answers').each(function(){
if(jQuery(this).find(":radio").is(':checked')==false){
jQuery(this).addClass('redhighlight');
}
else{
jQuery(this).removeClass('redhighlight');
}
}) ;
}



},10);




});

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/

if(jQuery('.ChoiceRow').length == jQuery('📻checked').length)
{
localStorage.clear();
localStorage.setItem("clicked", "No");
}
else{
localStorage.clear();
localStorage.setItem("clicked", "Yes");
}


});

Hope this helps 😀

Regards,
Samarth
Userlevel 2
Badge +2
Hi Samarth,

Thanks a lot for this. I will give this a go.

Thank you!
Kai
Dear Samarth,

I have been trying to implement the code you suggested above, but are encountering some problems.

When I paste the code above into the Javascript window of my matrix table question and click Save, the following error message appears:

!

Also, when I preview the questionnaire in the Qualtrics "Preview" option, the items are highlighted in red immediately once the question has loaded:

!

Can you perhaps guide me on how to change the code to (a) fix the error message above and (b) to only highlight the unanswered statements when the user clicks on "Next" to go to the next question?

The specific question currently has the "Request response" option activated.

Thank you for your help.

Regards,

Theuns
Userlevel 3
Badge +6
@tkotze, Did you ever find a solution for highlighting only the unanswered statements in a matrix?
@Samarth , bringing you again on this question, I have the same issues as @tkotze ... highlighting all the rows in red before even answering. Could you repeat step by step how to get the missed rows highlighted? Thanks

An old thread now, I know, but I would also be very interested in finding out how to highlight missed answers but only after the question has been attempted...

I would also be very interested in finding out how to highlight unanswered statements in a matrix table but only after the user has clicked next, thanks!

Userlevel 7
Badge +27

PsyTechMMU - You might be interested in this: https://www.qualtrics.com/community/discussion/comment/32225#Comment_32225

Userlevel 7
Badge +20

Please take a look at this one...
https://www.qualtrics.com/community/discussion/comment/32400#Comment_32400

Leave a Reply