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

How to change checkbox color and use these colors as condition?

Guest
Jun 26, 2020 Jun 26, 2020

Copy link to clipboard

Copied

Hello!


I have several checkboxes in my PDF, and I would like them to act as follows:
• When clicking once, the check appears in white.
• When clicking again, the check changes to green ["RGB", 0/255, 180/255, 160/255]
• When you click again, the check leaves. .value = "Off";

 

And then, I would like to use these colors as conditions for some ifs.
Something like this:
if (this.getField("Checkbox1").textColor == ["RGB", 0/255, 180/255, 160/255]) { something happen }

or

if (this.getField("Checkbox1").textColor == ["RGB", 1, 1, 1]) { something happen }

 

Is it possible to do these things? If so, how?

I tried, but was unsuccessful.

 

Thank you!

TOPICS
Acrobat SDK and JavaScript

Views

237

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 ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

To compare colors you must use the equal method of the color object. However, even that doesn't always work due to floating point issues, so I would recommend first rounding all the numbers in the array to 2 decimal points.

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 ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

LATEST

Hey asmjota,

 

I just posted an answer for another user which handles something similar to what you're looking for.

 

See here: https://community.adobe.com/t5/acrobat/fill-text-field-based-on-entry-of-another/m-p/11244439#M26375...

 

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