Highlighted

Unable to hide/reveal images like text

Community Beginner ,
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, Create PDFs, Edit and convert PDFs, General troubleshooting, How to

Views

275

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

Unable to hide/reveal images like text

Community Beginner ,
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, Create PDFs, Edit and convert PDFs, General troubleshooting, How to

Views

276

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
Jun 07, 2020 0
Adobe Community Professional ,
Jun 07, 2020

Copy link to clipboard

Copied

Check the Javascript console for errors.

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

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

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...
Jun 07, 2020 0
Community Beginner ,
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;

 

}

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...
Jun 07, 2020 0
try67 LATEST
Most Valuable Participant ,
Jun 07, 2020

Copy link to clipboard

Copied

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

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