Swap images based on field value

New Here ,
Sep 26, 2017

Copy link to clipboard

Copied

Looking for some assistance with a PDF. I have two images that I need to display based on a value in another field. If the value of field A is X then show image 1 is field is Y then show image 2. Is this possible?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use something like this as the custom validation script of the text field:

var b = event.value.indexOf("Voice")==0;

this.getField("Image1").display = b ? display.visible : display.hidden;

this.getField("Image2").display = !b ? display.visible : display.hidden;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

204

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

Swap images based on field value

New Here ,
Sep 26, 2017

Copy link to clipboard

Copied

Looking for some assistance with a PDF. I have two images that I need to display based on a value in another field. If the value of field A is X then show image 1 is field is Y then show image 2. Is this possible?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Use something like this as the custom validation script of the text field:

var b = event.value.indexOf("Voice")==0;

this.getField("Image1").display = b ? display.visible : display.hidden;

this.getField("Image2").display = !b ? display.visible : display.hidden;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

205

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
Sep 26, 2017 0
Most Valuable Participant ,
Sep 26, 2017

Copy link to clipboard

Copied

Yes, this is possible. Place the images as the icons of button fields and then show/hide those fields based on the value of field A.

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 26, 2017 0
New Here ,
Sep 26, 2017

Copy link to clipboard

Copied

Thanks I will give it a try.

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 26, 2017 0
New Here ,
Sep 27, 2017

Copy link to clipboard

Copied

I do not see where you can show or hide the buttons based on the value of the field? I do see the Actions but it  looks they require a interaction with the field to execute and there is nothing related to the field 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...
Sep 27, 2017 0
Most Valuable Participant ,
Sep 27, 2017

Copy link to clipboard

Copied

You would need to use a script, attached to the field. If you describe what

kind of field it is and what value should cause an image to appear or

disappear, I can help you with the actual code.

On Wed, Sep 27, 2017 at 4:29 PM, garabedy83334101 <forums_noreply@adobe.com>

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 27, 2017 0
New Here ,
Sep 27, 2017

Copy link to clipboard

Copied

That would be great! It is a text field that can have several values. If the value in the text field starts with a Voice then it would show image A anything else would show image B. Is that possible

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 27, 2017 0
Most Valuable Participant ,
Sep 27, 2017

Copy link to clipboard

Copied

Sure. What if the text field is empty, though?

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 27, 2017 0
New Here ,
Sep 27, 2017

Copy link to clipboard

Copied

Show image B

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 27, 2017 0
Most Valuable Participant ,
Sep 27, 2017

Copy link to clipboard

Copied

Use something like this as the custom validation script of the text field:

var b = event.value.indexOf("Voice")==0;

this.getField("Image1").display = b ? display.visible : display.hidden;

this.getField("Image2").display = !b ? 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 27, 2017 0
New Here ,
Sep 27, 2017

Copy link to clipboard

Copied

Thank you I will give it a try.

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 27, 2017 0
New Here ,
Sep 27, 2017

Copy link to clipboard

Copied

Does not seem to do anything. On the text field I selected Run custom validation script with the following.

var b = event.value.indexOf("Voice")==0; 

this.getField("Image3_af_im").display = b ? display.visible : display.hidden; 

this.getField("Image4_af_im").display = !b ? 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 27, 2017 0
Most Valuable Participant ,
Sep 27, 2017

Copy link to clipboard

Copied

Change the value of the field for it to kick in, and check the JS-Console (Ctrl+J) for error messages.

If there are none and it still doesn't work, share the file and I'll check what's going on.

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 27, 2017 0
New Here ,
Sep 27, 2017

Copy link to clipboard

Copied

I created a fresh form and now it works. Thanks for your help !

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 27, 2017 0