0

I am new at Acrobat, Need some help in conditional Formatting, I have 2 text fields. If I enter a number >0 but <10 the bg colour of the second box should turns yellow. If I enter a number <20 but >10 it should turns orange.

Please help to understand Acrobat DOM elements.

  • Get the Acrobat JavaScript documentation (which is part of the Acrobat SDK documentation), and you will find the Field object with its properties. (but nevertheless, see my answer). – Max Wyss Jan 08 '16 at 00:25

1 Answers1

0

Let's assume the field where you enter the numbers is called "myField". Then, we would add the following to the Calculate event of the field where the background should change:

var mf = this.getField("myField") ;
if (mf.value > 0 && mf.value < 10) {
event.target.fillColor = color.yellow ;
} else {
if (mf.value >= 10 && mf.value < 20) {
event.target.fillColor = ["RGB", 1, 0, 0.2] ; 
} else {
event.target.fillColor = ["T"] ;
}
}

and that should do it.

Note that there is no pre-defined orange color, and you'd have to get the correct color value array (I think the one I used is kind of an orange).

If you add the code to the calculate event of another field, you'd have to replace event.target with this.getField("myOtherField") (or whatever the field name is).

Max Wyss
  • 3,549
  • 2
  • 20
  • 26