Adding color to individual matrix drag and drop boxes | XM Community
Skip to main content

Hi all! I would like to to change the color of each of my individual matrix boxes, but I can't work out how to do it. I've seen another post here that achieves what I want, but using the multiple choice options - I can't work out how to change this code so that it works with the matrix drag and drop boxes.

Here is the code that I am talking about from the referenced post:
var c=["#f9f9f9","#ececec","#ececec","#dfdfdf","#dfdfdf","#d3d3d3","#d3d3d3","#c6c6c6","#c6c6c6","#b9b9b9","#acacac"];
for(var i=0;i<=11;i++){
jQuery("#"+this.questionId+" label.SingleAnswer:eq("+i+")").css("background",c[i]);
}

And here is the question format I am trying to achieve it on:
Screen Shot 2022-05-15 at 18.37.48.png
Any help is really appreciated!

Hi mb2674,
It just needs a little tweaking based on the class names.
Give this a go:
var c=["#dedede","#c2c2c2","#ababab","#808080"]; //or whatever other colours you want
for(var i=0;i<=3;i++) {
jQuery("#"+this.questionId+" ul.AnswerBucket:eq("+i+")").css("background-color",c[i]);
}
EDIT: here is a screenshot of the result
image.png


https://community.qualtrics.com/XMcommunity/discussion/comment/46274#Comment_46274Thank you so much!


No worries 🙂 If my solution solves your problem, please accept it as the answer so other users can find it easier.


Leave a Reply