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

change fill color of a field depending on checkbox

New Here ,
Aug 20, 2019 Aug 20, 2019

Copy link to clipboard

Copied

hello,

I have a checkbox and would like to change the color of an other field depending on activating the checkbox.

the other field isn't an empty field, there is already text in it. is it possible only to change the background color of this field if the checkbox is activated?

name.jpg

can you please help me

TOPICS
Acrobat SDK and JavaScript

Views

3.1K

Translate

Translate

Report

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 ,
Aug 21, 2019 Aug 21, 2019

Copy link to clipboard

Copied

Sure. As the Mouse Up event of the check-box field you can use something like this:

this.getField("Text1").fillColor = (event.target.value=="Off") ? color.transparent : color.yellow;

Votes

Translate

Translate

Report

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
New Here ,
Mar 26, 2020 Mar 26, 2020

Copy link to clipboard

Copied

For me this works great on the form iteself, but I am passing data to the form from an outside program.  The Mouse Up event doesn't work.  The check boxes do come out as checked when the PDF is generated, but not the Mouse Up javascript fill colors.  Is there another method that might work?

Votes

Translate

Translate

Report

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 ,
Mar 26, 2020 Mar 26, 2020

Copy link to clipboard

Copied

LATEST

How is the data loaded? If it is from an FDF file, then the FDF can contain a script to setup the correct color values.

 

If the form is open in Acrobat when the data is loaded, then you can use a script that is triggered by a data change. The calculate event is an obvious choice since it's triggered any time anything changes, any calculation script on any field will work for this. But you have to be careful for the same reason.  

 

If the data is merged into the PDF external to Acrobat, then you need a document level script that sets the colors when the PDF is opened in Acrobat.  

 

 

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

Votes

Translate

Translate

Report

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