I am building a survey where we provide a matrix and we only want the respondent to fill out specific rows of the matrix, not all rows. Does anyone know a code where I can highlight specific rows to have a different background color to identify which rows we want the respondent to fill out? I do not want the code to make alternating shading of rows. Thanks!
You could add a span with a class of 'hilite' to all the statement rows you want to highlight, like:
Statement text
Then use this JS:
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .hilite").each(function() {
jQuery(this).closest("tr").css("background-color","yellow");
});
});
TomG thanks for your response. do I add the span in the javascript? or where do I put it? also, where do I identify which row to highlight in the javascript?
https://community.qualtrics.com/XMcommunity/discussion/comment/41157#Comment_41157You put the span(s) in the statement text of your matrix rows. The JS will find the rows for you.
TomG this works great, thank you. the only problem is now when i preview the survey, it has "statement text" written out after my statement text. is there a way to get rid of this? thanks.
https://community.qualtrics.com/XMcommunity/discussion/comment/41159#Comment_41159"statement text" was only an example. It was meant to be whatever your row label text is. Since you've already done it, you can just delete "statement text" and leave the span empty. It will still work.
TomG I solved this problem, thank you so much for your help!
TomG Hi Tom, sorry to bother you again.
this worked for all questions except two. for some reason, in two of my questions, the highlighting is applying to the entire matrix, even though i only entered the span into some questions. any idea why this is happening? Thanks!
https://community.qualtrics.com/XMcommunity/discussion/comment/41163#Comment_41163Hard to say without seeing it. It may be a missing a closing tag (e.g.,
) or a typo in the html.Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.