Dynamic label color based on response

Is there a way to dynamically change the color of the label based on the value of the response. We have a survey with select questions with 3 options Yes, No, No response, codes 1,2,3 respectively. Is there a way to change the color of the label of the questions based on the responses, say, if response is Yes(1), the color of the question changes to green, if No (2), the color changes to red, and gray if value 3.

Both in collect and enketo webform. Btw, we are using ODK Central.

Thank you.

Cheers,
Vinia

There is not a way to change the styling of an option in the list after selecting that option. You can adjust the font and colors but it is a static adjustment.

3 Likes

I agree with @danbjoseph that options can't be styled in a list. Is it the color of the label that you want to change? The label of a question can't be updated by its own value. However, you can achieve roughly what you want by conditionally setting the style of another note in the same field list. It's a bit clunky but see what you think of this example and perhaps it will give you some ideas.

3 Likes

Thanks, Hélène. This works in Collect. Doesn't work in Enketo though.
(@martijnr Hi Martijn :slightly_smiling_face:, I hope there's a way to make this work in Enketo. Regards.)

Cheers,
Vinia

1 Like

Would be a big project, since Enketo currently evaluates all the formatting before the form is served to the browser, so there is no client-side processing. Enketo would need to change that approach (and not do both).

2 Likes

Got that. Thanks, Martijn!