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

MMm.. that's weird. Would you mind sharing an screenshot of the current state of your field style?



Thanks,


Berny


See below:-



Style5.PNG


Thanks Angus! I was referring to the screenshot of the page where we are defining the style . The same one you shared when you entered this post.



The objective is to check if we can observe anything that may still have to be changed on your condition or in your style.



Thanks,


Berny


This one Berny?


Style6.PNG


MMm.. Yes. That one. And that's not displaying a blue circle next to the contact type when it is Site Surgery? Keep in mind this styles will only work in the list view . To do it within a form, you will need to do an onload or onchange client script that will modify the element style.



Thanks,


Berny