How to change a single box colour (multiple choice) | XM Community
Solved

How to change a single box colour (multiple choice)

  • 15 May 2019
  • 3 replies
  • 202 views

Userlevel 1
Hi everybody

I need to set a different color for every box of my multiple choice question.
(e.g. red for the first box, green for the 10th box)!


Has anyone a code to be implemented?

Thanks in advance
icon

Best answer by fleb 16 May 2019, 09:31

View original

3 replies

Userlevel 5
Badge +6
Check this discussion.
Userlevel 1
> @fleb said:
> Check this discussion.

Thanks so much it works fine!

The only problem is that the selected choice is not highlighted anymore, so you are not able to recognize which option you have chosen.. could you please help?
Userlevel 5
Badge +6
Hi,
even though I think that there should be a more elegant solution, I don't see any other option than recolor all options again every time when user clicks the question:

this.questionclick = function(event, element) {
for(var j=0;i<=11;j++){ jQuery("#"+this.questionId+"
label.SingleAnswer:eq("+j+")").css("background",c[j] + "!important");}}

However, you might face to the problem that your respondents won't see which option is checked once it looses its focus. You could solve it by modifying outline or box-shadow for the `.q-checked` class. See this discussion for inspiration. (If you want to modify just your question, you should put id of your question in form `#QIDx` where x is id of your question before class name).

Leave a Reply