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

How to achieve conditional formatting in PDF

Community Beginner ,
Oct 24, 2021 Oct 24, 2021

Copy link to clipboard

Copied

Hello, I tried to set up some conditional formating on a PDF form and am hot sure where it went wrong. Here's what I hoped to achieve: I configured three check-box field "Check Box5.0.0.0", "Check Box5.1.0", and "Check Box5.2.0.0", and I want the three box to be filled with green, red, and purple if they're checked individually.

Screen Shot 2021-10-24 at 10.08.41.png

I confugured them to run a Javascript, with Mouth Up as the trigger, and the code is below:

 

if(event.target.value != "Off")

    this.getField("Check Box5.0.0.0").fillColor = color.yellow;

else

    this.getField("Check Box5.0.0.0").fillColor = color.transparent; 

 

I edited the form on MacOS and it seems to be working, but when I later open it up on a PC, it behaves really strange. Same thing happened when I opened it on a differnet Mac. Once I checked another box, it'll clear up the color for the previous check-box. Not sure where I got it wrong. Thanks!

 

ezgif-7-7bee623e51dc.gif

TOPICS
Acrobat SDK and JavaScript

Views

275

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
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 25, 2021 Oct 25, 2021

You have to disable fields highlighting in order to see the fill color of the fields when they are not in focus.

Likes

Translate

Translate
Community Expert ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

What software you use on PC?

Did you work in preview mode on your Mac?

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
community guidelines
Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

All machines are using the latest version of Acrobat Pro. 

Can you clarify what do you mean in preview mode? I'm not using the Preview app that comes with MacOS, that video is taken on a PC.

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
community guidelines
Community Expert ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

Could you share your file here so we can take a look?

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
community guidelines
Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

Sure thing. I only configured the code for the first line BTW.

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
community guidelines
Community Expert ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

It works fine for me.

Do you have any other scripts in your file?

Try using script like this:

event.target.fillColor = event.target.value == "Off" ? color.transparent : color.red;

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
community guidelines
Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

LATEST

Turns out it's an issue with disabling fields highlighting so the filled color will show when the check box is not being selected. But thanks for the code. It definitely made my life easiler configuing all those individual check boxes.

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
community guidelines
Community Expert ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

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
community guidelines
Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

It's still behaving strangly once I open it on PC. I edited the file a bit so the four check boxes don't change color at the same time. For some reason it's still not working.

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
community guidelines
Community Expert ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

You have to disable fields highlighting in order to see the fill color of the fields when they are not in focus.

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
community guidelines
Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

That's it!!!! I added a document script to disable highlighting and it works like magic! Thank you so much!

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
community guidelines