Using Syle to highlight a field

amacqueen
Mega Guru

The picture below shows what I've done to get a field highlighted based on the fields value

Style.PNG

I have a feeling that I may have got the syntax wrong as this field is a string and not an integer/choice field.

I would welcome any feedback.

TIA

1 ACCEPTED SOLUTION

Angus,


Use the below code:



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


  var cTypeLabel = $('label.incident.contact_type');


  var cTypeField = $('incident.contact_type');



if (newValue == 'Self Service') {


  cTypeLabel.setStyle({backgroundColor: "red"});


  cTypeField.setStyle({color: "red"});


  }


  else {


  cTypeLabel.setStyle({backgroundColor: ""});


  cTypeField.setStyle({color: ""});


  }



}


View solution in original post

30 REPLIES 30

Just a small correction - Styles will be applied to certain field types in form view if they are read-only:


____Jim_C_____.png


what color are you using right now?


I'm using Blue now Doug


ok i think we are making this way more complex than it has to be... you want to adjust the background of the same field you are triggering off of so no javascript is required...



for value try putting in "Site Surgery"


for style put in background-color:SkyBlue




and see if it works.



saritha9
Giga Expert

Agree with Berny.