Skip to main content
Participant
July 30, 2020
Answered

Conditional formatting based on value of another form field

  • July 30, 2020
  • 2 replies
  • 3625 views

Hello! I need to change bg color of a field simply based on the text contents of another field on a different page. I've been researching for hours trying to find this seemingly simple code and tried numerous times based on other forums but have been unsuccessful. I have come across numerous answers for numerical values and calculations but nothing for a simple text input.

 

For example, I need the "RingGear" field on page 1 to be highlighted green if the value of "RingGearValue" (on page 4)  = "OK", and highlighted red if the value "RingGearValue" = "CAUTION", otherwise transparent.

 

Thank you!

This topic has been closed for replies.
Correct answer Nesa Nurani

Use this as Custom calculation script of "RingGear" field

var e = this.getField("RingGearValue").value;
var f = this.getField("RingGear");
if( e == "OK"){
  f.fillColor = color.green;
}else
 if( e == "CAUTION"){
  f.fillColor = color.red;
}else f.fillColor = color.transparent;

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
July 30, 2020

Use this as Custom calculation script of "RingGear" field

var e = this.getField("RingGearValue").value;
var f = this.getField("RingGear");
if( e == "OK"){
  f.fillColor = color.green;
}else
 if( e == "CAUTION"){
  f.fillColor = color.red;
}else f.fillColor = color.transparent;
Dana2203Author
Participant
July 30, 2020

Thank you so much! Just what I needed. I appreciate the help very much!

Bernd Alheit
Community Expert
Community Expert
July 30, 2020

You can check the content of text fields like this:

if (this.getField("RingGearValue").value  == "OK") {

 

}