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

Conditional Formatting to Fill a text box color IF a different box has text

New Here ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

I want to make a box colored yellow to highlight a signature on a page if there is text in another box on that same page. 

I have put this code in the Text Field Properties > Validate > Run custom validation script

if (event.value= (this.getField("Text_Box_With_Text_if").valueAsString=="")) event.target.fillColor = color.yellow;

else event.target.fillColor = color.transparent;

 

I have the Border color and fill color set to "No Color" in the appearance tab.

What is going wrong?

Thanks in advance.

TOPICS
Acrobat SDK and JavaScript

Views

1.3K

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 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

Change this:

if (event.value= (this.getField("Text_Box_With_Text_if").valueAsString==""))

To:

if (event.value=="")

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 ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

Or, if you want it to be based on another field's value, then change that line to:

if (this.getField("Text_Box_With_Text_if").valueAsString=="")

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 ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

Thank You! (I'm using your code from previous posts and I want you to know that I don't think Adobe is paying you enough for your work)

Is there also a way to layer words on a PDF over the colored box so that it acts as a highlighter for words and the box with the code behind the words? Right now if I have a highlighted box it will go over anything on the PDF. I want it to act like the highlighter tool in the comment tool section but to have the conditional formatting.

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 ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

Not entirely sure what you mean, but you can set the fill color of the box as transparent. However, you can't change its opacity level, like you can with a comment. It's either transparent or it's not.

 

And I don't work for Adobe...

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 ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

Or you could actually use a comment... Those can be created and edited using a script, too.

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 ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

So I want to make it so that if this box is checked, the highlight tool shows up. Otherwise, it is not there. Where do I need to go to input the code and what is the code needed?Adobe Help.PNG

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 ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

Go to CheckBox properties->Action->MouseUp->Run Javascript add this code:
if(event.target.value != "Off"){
this.getAnnot(0,"Your annot name goes here").hidden = true;}
else
this.getAnnot(0,"Your annot name goes here").hidden = false;

To find your annot name, select your annot(example: rectangle) and press CTRL+J
now in console paste this code:
this.selectedAnnots[0].name;
and press Enter to get name, now copy that name and put it into code where says "Your annot name goes here".

 

EDIT: I assume you want to show/hide highlight text next to checkbox?

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 ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

Joe5CBE_1-1599063075599.png

If the box is checked I want the highlight to show up, if not I don't want highlight. When I paste your code into JavaScript Debugger (CTR+J on Comment > Highlighter tooled section of pdf) and press enter nothing happens. 

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 ,
Sep 03, 2020 Sep 03, 2020

Copy link to clipboard

Copied

LATEST

Again, I want to have it so if a checkmark box is checked ("Yes") then the words on the PDF "Signature of Owner's Spouse" are highlighted yellow. If the box is not checked then no highlight. Hoping someone can give me clear steps because I don't know where to input this code.

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 ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

Hi, you could achive this if you replace text box with image field and input photo with desired opacity, and use script in another field to show/hide image field. 

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

@try67

What would be the coding for if the current text field has text then change the border color to black.

Else border is transparent.

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Hi, you can use this code:

if(event.value != ""){
event.target.borderColor = color.black;}
else event.target.borderColor = color.transparent;

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 ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

"Hi, you could achive this if you replace text box with image field and input photo with desired opacity, and use script in another field to show/hide image field." 

If I wanted to do this and hide/show an image field based on if a checkmark box is checked what would the code be and where would I insert it?

 

Likes

 

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 ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

Insert code in checkbox mouseUp event

this.getField("Image2_af_image").display = event.target.value != "Off" ? display.visible : display.hidden;

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 ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

Do I run a JavaScrpit?

Joe5CBE_0-1599063965540.png

 

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 ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

Yes

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