Adding color to individual matrix drag and drop boxes | XM Community
Solved

Adding color to individual matrix drag and drop boxes


Badge +1

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!

icon

Best answer by bgooldfed 16 May 2022, 06:44

View original

3 replies

Userlevel 5
Badge +25

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

Badge +1

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

Userlevel 5
Badge +25

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

Leave a Reply