Change font colors with a calculation in Survery123

1141
1
03-14-2019 07:09 AM
GrantHaynes
Occasional Contributor

Hi everyone,

I'm just wondering if it's possible to change a fields font or background color in Survey123 based on a calculation. I have a form where we have a lot of stability calculations, I'd like to change the background or text color if the values entered in the form are within a certain range. Right now I have calculated fields that indicate if the values are within range, which works well enough, I'd just like to simplify the form.

Tags (1)
1 Reply
BrandonArmstrong
Esri Regular Contributor

Hi Grant,

This could be possible by specifying something like the following in the calculation column...

concat('<font color="', if(selected(${example}, 'red'), "red", ""),'">Text in changes color </font>')

typenamelabelcalculation
select_one colorexampleExample
notediffctestconcat('<font color="', if(selected(${example}, 'red'), "red", ""),'">Text in changes color </font>')

This will lead to the font color of the label changing to red if red is selected in the previous question, or, remain the default color in the event that nothing or something else is selected.

I have also included the XLSForm as an attachment to this thread, which contains this example.

Best,

Brandon