Highlighted

hide and show image fields based on value

Explorer ,
Nov 09, 2020

Copy link to clipboard

Copied

I have two image fields and images are read only. I have a text field and I want to swop images based on values. If the value is 0 or less than 0 like - 1 image1 and if +1 or greater than +1 then image2.

 

Is this possible?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Sure. As the custom validation script of the text field enter the following:

this.getField("image1").display = (event.value<=0) ? display.visible : display.hidden;

this.getField("image2").display = (event.value>0) ? display.visible : display.hidden;

TOPICS
PDF forms

Views

43

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

hide and show image fields based on value

Explorer ,
Nov 09, 2020

Copy link to clipboard

Copied

I have two image fields and images are read only. I have a text field and I want to swop images based on values. If the value is 0 or less than 0 like - 1 image1 and if +1 or greater than +1 then image2.

 

Is this possible?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Sure. As the custom validation script of the text field enter the following:

this.getField("image1").display = (event.value<=0) ? display.visible : display.hidden;

this.getField("image2").display = (event.value>0) ? display.visible : display.hidden;

TOPICS
PDF forms

Views

44

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
Nov 09, 2020 0
Most Valuable Participant ,
Nov 09, 2020

Copy link to clipboard

Copied

Sure. As the custom validation script of the text field enter the following:

this.getField("image1").display = (event.value<=0) ? display.visible : display.hidden;

this.getField("image2").display = (event.value>0) ? 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...
Nov 09, 2020 0
Adobe Community Professional ,
Nov 09, 2020

Copy link to clipboard

Copied

You can read all about Hide/Show scripts here:

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm?sd=40

 

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...
Nov 09, 2020 0
Explorer ,
Nov 09, 2020

Copy link to clipboard

Copied

Really magic. Just one more question. If the value is 0 then both images should be hidden. Can you please modify 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...
Nov 09, 2020 0
Adobe Community Professional ,
Nov 09, 2020

Copy link to clipboard

Copied

You can see that the condition on the first line of code is   event.value<=0  . This is read as "when the value is less than or equal to 0" .  When the codition is satisfied the display setting for the field is set to display.visible .  I think you can see how this works. If you want both images to be hidden, then the condition needs to be modified so that it is not true when the value is 0, i.e., remove the equals.

 

 

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...
Nov 09, 2020 0
Explorer ,
Nov 10, 2020

Copy link to clipboard

Copied

So kind of you. Thank you!

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...
Nov 10, 2020 0