Background Color on a choice list

Sam Ogden
Tera Guru

Hi All,

I have just added a choice list to our incident form with the choice options of Red, Amber & green.   I want the background colour of the field to match these descriptions.   I've added in 3 styles on this field:

find_real_file.png

On the list view this is presenting a coloured dot which is what I want:

find_real_file.png

However on the actual form the background colour does not change:

find_real_file.png

Is there a way to make the background colour also change on the form?

Thanks

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Sam,



You can use below script


find_real_file.png



only thing is to have the field name changed as desired & additional else condition added if required. Also, in place of riskimpact == '1' you can have your choice name added as riskimpact == 'amber' etc.



Thanks,


Jaspal Singh



Hit Like or Correct on the impact of response.


View solution in original post

10 REPLIES 10

Rajesh Mushke
Mega Sage
Mega Sage

Hi Sam,



Create onChange client on your field,



for me i have created on Incident   table : State field,



Please Replace your table name & Field name in the below code




function onChange(control, oldValue, newValue, isLoading) {



  var elementID = gel("incident.state");


  switch (newValue) {


      case "1":


          elementID.style.backgroundColor = "Gray";


          break;


      case "2":


          elementID.style.backgroundColor = "tomato";


          break;


      case "3":


          elementID.style.backgroundColor = "orange";


          break;


      case "4":


          elementID.style.backgroundColor = "yellow";


          break;


      case "5":


          elementID.style.backgroundColor = "green";


          break;


      default:


          elementID.style.backgroundColor = "Lightgreen";


          break;


  }


}




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Hi Rajesh,



I've just tried to amend the code, but it is not working.   The field is :


find_real_file.png


find_real_file.png




And the Code is:



find_real_file.png



But still the background colour remains standard:



find_real_file.png



Thanks


Hi Sam,



Remove your 2nd line,3rd line,4th line of code and try again.




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

I've tried this but still only changing the colour on the list view and not changing it on the form.