Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Conditional formatting form field based on another field

Community Beginner ,
Feb 02, 2020 Feb 02, 2020

Hi Community,

I would like to highlight red the 'Dew Point' field when the value is 3 or more below the 'Steel Surface Temp' field. (ie Steel Surface = 40, Dew = 37, field = red).

Have managed to highlight red another field based on a value range, but am having trouble highlighting based of other fields.

 

Feel free to throw in any tips to help my understanding 🙂

Cheers!

 


Capture.PNG

TOPICS
PDF forms
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Feb 03, 2020 Feb 03, 2020

Hi JR, I think he's looking for the difference between the two values. Here's a modification of the scirpt

 

if ((this.getField("Steel Surface Temp").value-event.value) >= 3) {event.target.fillColor = color.red;}
else {event.target.fillColor = color.transparent;}

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2020 Feb 03, 2020

Use this as a Calculation script in the Dew Point field:

 

if (this.getField("Steel Surface Temp").value >= 3) {event.target.fillColor = color.red;}
else {event.target.fillColor = color.transparent;}


Acrobate du PDF, InDesigner et Photoshopographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 03, 2020 Feb 03, 2020

Thanks JR!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2020 Feb 03, 2020

Hi JR, I think he's looking for the difference between the two values. Here's a modification of the scirpt

 

if ((this.getField("Steel Surface Temp").value-event.value) >= 3) {event.target.fillColor = color.red;}
else {event.target.fillColor = color.transparent;}

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 03, 2020 Feb 03, 2020

Works like a charm, thanks Thom.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 03, 2020 Feb 03, 2020

Thom, how do I adjust the script to fillcolor red if 3 above OR below the "Steel Surface Temp"

 

Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2020 Feb 04, 2020

Use the Absolute value of the difference for the comparison.

 

if (Math.abs(this.getField("Steel Surface Temp").value - event.value) >= 3)

{event.target.fillColor = color.red;}
else {event.target.fillColor = color.transparent;}

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 04, 2020 Feb 04, 2020

thanks again Thom

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2020 Feb 04, 2020

I still need to improve my understanding of English

😉


Acrobate du PDF, InDesigner et Photoshopographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2020 Feb 04, 2020

You are doing great!!

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 04, 2020 Feb 04, 2020

Thom, just have to say your tutorials on pdf scripting dot com have been a great help to my current form projects. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2020 Feb 05, 2020
LATEST

Thom's tools and tutorials are in first place in my list of PDF & JavaScript resources, even for French speakers.

See : https://www.abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/ressources-pdf-javas...

🙂


Acrobate du PDF, InDesigner et Photoshopographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines