Highlighted

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

New Here ,
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, How to

Views

73

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

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

New Here ,
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, How to

Views

74

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 28, 2020 0
Most Valuable Participant ,
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=="")

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 28, 2020 0
Most Valuable Participant ,
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=="")

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 28, 2020 0
New Here ,
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.

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 28, 2020 0
Most Valuable Participant ,
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...

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 28, 2020 0
Engaged ,
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. 

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 28, 2020 0
Most Valuable Participant ,
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.

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 28, 2020 0
New Here ,
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

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...
Sep 01, 2020 0
Engaged ,
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?

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...
Sep 01, 2020 0
New Here ,
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. 

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...
Sep 02, 2020 0
Joe5CBE LATEST
New Here ,
Sep 03, 2020

Copy link to clipboard

Copied

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.

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...
Sep 03, 2020 0
New Here ,
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.

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 31, 2020 0
Engaged ,
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;

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 31, 2020 0
New Here ,
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

 

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...
Sep 01, 2020 0
Engaged ,
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;

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...
Sep 01, 2020 0
New Here ,
Sep 02, 2020

Copy link to clipboard

Copied

Do I run a JavaScrpit?

Joe5CBE_0-1599063965540.png

 

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

Copy link to clipboard

Copied

Yes

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