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

Unable to hide/reveal images like text

Community Beginner ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Hey all,

 

I'm working on a project where I need the choice on a dropdown menu to reveal and hide certain fields. I wrote a code that works just fine for text fields but will not work with an image field. Code below:

 

switch(event.value) {

 

case "Option A":

this.getField("Text 1").display=display.visible;
this.getField("Text 2").display=display.hidden;
this.getField("Image 1").display=display.visible;
this.getField("Image 2").display=display.hidden;
break;

 

case "Option B":

this.getField("Text 1").display=display.hidden;
this.getField("Text 2").display=display.visible;
this.getField("Image 1").display=display.hidden;
this.getField("Image 2").display=display.visible;
break;

 

}

 

With this code applied to my Dropdown field my Text fields swap just fine, but the Images remain visible no matter the dropdown option chosen. Another thing I noticed is that whenever I rename an Image field it becomes a Button automatically. I thought that might be the issue, but I adjusted the code for the auto-populated Image field name and still had the same issue. Are Images and/or Buttons unable to be hidden/revealed, or is there a setting I am missing somewhere?

 

Cheers!

TOPICS
Acrobat SDK and JavaScript

Views

813

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 ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Check the Javascript console for errors.

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 Beginner ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Hi Bernd,

 

I am getting this from the Debugger:

SyntaxError: syntax error
1:Console:Exec
undefined

 

However, when I remove the image code and just include the text field codes in the debugger I get the same error message. But if I utilize the text-field-only code in my Custom Calculation Script, the text fields behave exactly as intended when the different dropdown options are selected.

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 ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Add the code again, change the value of the field and then check the JS Console once more.

That error is from something you executed from the Console. It has nothing to do with it.

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 Beginner ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Sorry, still very new to this. What do I need to chance the fields to? I only have 5 fields in the document (dropdown, x2 text and x2 image). With only the text fields utilized (see code below) there aren't any other available fields for troubleshooting other than the image fields, which were the intial problem. And this code works fine in the Custom Calculation Script. I just can't get the same results from: this.getField("variable").display=display.hidden; if the variable is an image or a button field.

 

switch(event.value) {

 

case "Option A":

this.getField("Text 1").display=display.visible;
this.getField("Text 2").display=display.hidden;
break;

 

case "Option A":

this.getField("Text 1").display=display.hidden;
this.getField("Text 2").display=display.visible;
break;

 

}

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 ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Please follow our instructions. Try the full code and check for errors.

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
Participant ,
Apr 25, 2021 Apr 25, 2021

Copy link to clipboard

Copied

I am suffering from exactly the same symptoms.
Only the image field is not hidden.

 

var PAPA1 = this.getField ("PAPA_1");            //Text Field
var MAMA1 = this.getField ("MAMA_1");         //Image Field

 

PAPA1.display = display.hidden;                    //It disappears from the screen.
MAMA1.display = display.hidden;                  //It doesn't disappear from the screen.

 

No error appears here.

It just doesn't disappear.

 

 

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 ,
Apr 25, 2021 Apr 25, 2021

Copy link to clipboard

Copied

LATEST

Can you share the file with us?

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