This example will show you how to format the colour of a dropdown menu using a JavaScript label.
Script
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// The first line of code specifies the field you want to apply the colour changes to
var fieldid = 6400
var fieldnode = $('#CustomField_'+fieldid)
// The section below implements which colour should be displayed when each option on the dropdown is chosen
switch (fieldnode.val()) {
case ('Low'):
//The colour you want to use can be changed by simply editing the text to your colour of choice
fieldnode.css('background-color','green');
break;
case ('Medium'):
fieldnode.css('background-color','orange');
break;
case ('High'):
fieldnode.css('background-color','red');
break;
} |
High risk
This screenshot shows the dropdown field when the "High" option is selected.
Medium risk
This screenshot shows the field when the "Medium" option is selected
Low risk
The final screenshot shows the field when the "Low" option is selected.