Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This example will show you how to format the colour of a dropdown menu using a JavaScript label.

Script

 

Code Block
languagejs
titleChanging colours
linenumberstrue
// 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

Image Added

 

This screenshot shows the dropdown field when the "High" option is selected.

 

Medium risk

 

Image Added

 

This screenshot shows the field when the "Medium" option is selected

Low risk

 

Image Added

 

The final screenshot shows the field when the "Low" option is selected.