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

Swap images based on field value

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

TOPICS
Acrobat SDK and JavaScript , Windows

Views

687

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

correct answers 1 Correct answer

Community Expert , Sep 27, 2017 Sep 27, 2017

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;

Votes

Translate

Translate
Community Expert ,
Sep 26, 2017 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.

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

Copy link to clipboard

Copied

Thanks I will give it a try.

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

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

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

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

Show image B

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

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

Copy link to clipboard

Copied

Thank you I will give it a try.

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

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

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

Copy link to clipboard

Copied

LATEST

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

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