change fill color of a field depending on checkbox

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

743

Likes

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

change fill color of a field depending on checkbox

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

744

Likes

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
Aug 20, 2019 0
Most Valuable Participant ,
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;

Likes

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
Reply
Loading...
Aug 21, 2019 0
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?

Likes

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
Reply
Loading...
Mar 26, 2020 0
Adobe Community Professional ,
Mar 26, 2020

Copy link to clipboard

Copied

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.  

 

 

Likes

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
Reply
Loading...
Mar 26, 2020 0