How to dynamically change an choice graphic when answer is selected? | XM Community
Question

How to dynamically change an choice graphic when answer is selected?

  • 9 April 2021
  • 1 reply
  • 61 views

Userlevel 1
Badge

On horizontal single-choice multiple choice questions, we're going to add some icon graphics below the text choices. On our theme, when the choice is selected the choice background turns blue. The image may look good when unselected, but doesn't look as good when selected (on the blue background).
There are various tips for this on this community post: https://www.qualtrics.com/community/discussion/1081/using-images-in-questions-how-do-i-change-how-the-selected-image-and-non-selected-images-display
But is there a way (like with custom code) to dynamically switch to a second image when the choice is selected (an image which looks better on a blue background)? Can it be done somehow using https://s.qualtrics.com/WRAPI/QuestionAPI/classes/Qualtrics%20JavaScript%20Question%20API.html ?
Disclaimer: I have some in-house javascript-coding expertise, but we're new to Qualtrics custom coding.


1 reply

Userlevel 7
Badge +21

All options will have either

q-radio
or
q-checkbox
class. Selecting a choice adds the class
q-checked
to it. So you can use a mutation observer to switch the image src.

Leave a Reply