4 Replies Latest reply on Jun 2, 2015 12:30 AM by try67

    Script to include a change of background colour dependent on response

    tbrookes3 Level 1

      I previously obtained help from a user here to create a script that autopopulates a field based on options selected in two sets of radio buttons:

       

      var consequence = this.getField("Consequence").valueAsString; 

      var likelihood = this.getField("Likelihood").valueAsString; 

           

      if (consequence=="Insignificant" && likelihood=="Rare") event.value = "Low"; 

      else if (consequence=="Insignificant" && likelihood=="Unlikely") event.value = "Low";

      else if (consequence=="Insignificant" && likelihood=="Moderate") event.value = "Low";

      else if (consequence=="Insignificant" && likelihood=="Likely") event.value = "Low";

      else if (consequence=="Insignificant" && likelihood=="Almost Certain") event.value = "Moderate"; 

      else if (consequence=="Minor" && likelihood=="Rare") event.value = "Low"; 

      else if (consequence=="Minor" && likelihood=="Unlikely") event.value = "Low";

      else if (consequence=="Minor" && likelihood=="Moderate") event.value = "Moderate";

      else if (consequence=="Minor" && likelihood=="Likely") event.value = "Moderate";

      else if (consequence=="Minor" && likelihood=="Almost Certain") event.value = "High"; 

      else if (consequence=="Moderate" && likelihood=="Rare") event.value = "Low"; 

      else if (consequence=="Moderate" && likelihood=="Unlikely") event.value = "Moderate";

      else if (consequence=="Moderate" && likelihood=="Moderate") event.value = "High";

      else if (consequence=="Moderate" && likelihood=="Likely") event.value = "High";

      else if (consequence=="Moderate" && likelihood=="Almost Certain") event.value = "Critical"; 

      else if (consequence=="Major" && likelihood=="Rare") event.value = "Low"; 

      else if (consequence=="Major" && likelihood=="Unlikely") event.value = "Moderate";

      else if (consequence=="Major" && likelihood=="Moderate") event.value = "High";

      else if (consequence=="Major" && likelihood=="Likely") event.value = "Critical";

      else if (consequence=="Major" && likelihood=="Almost Certain") event.value = "Extreme"; 

      else if (consequence=="Catastrophic" && likelihood=="Rare") event.value = "Moderate"; 

      else if (consequence=="Catastrophic" && likelihood=="Unlikely") event.value = "High";

      else if (consequence=="Catastrophic" && likelihood=="Moderate") event.value = "Critical";

      else if (consequence=="Catastrophic" && likelihood=="Likely") event.value = "Extreme";

      else if (consequence=="Catastrophic" && likelihood=="Almost Certain") event.value = "Extreme";

      // etc. 

      else event.value = ""; 

       

      I'm wondering if its possible to have the colour of the field that uses the above script, change based on the entry. E.g. If the answer is Low; make the background colour Green; if its Moderate, make it orange etc.?

       

      I know its a big ask but thought I would check.

       

      Thanks in advance.