Skip to main content
JMou3493
Participant
July 22, 2021
Question

HELP! Drop down box turns on image visibility?

  • July 22, 2021
  • 2 replies
  • 495 views

Hello all,

 

I'm trying to create a PDF form in Adobe Acrobat Pro DC which has a drop down menu. When the user selects an item from the menu it will toggle the visibility of the corresponding image below. 
I've imported the first image and I'm trying to get it to work but I can't seem to make the JavaScript run. 

I set the JavaScript to run through the drop down box's custom calculation script. My code is below:

--------------

//Get dropdown reference value

//TCE1 will return a value of 1 when the first image's text is selected

var DD1 = this.getField("TCE1").value

//Get reference to the image

var PCMS1 = getField("PCMS1")

//hide image on startup

PCMS1.display=display.hidden

//show image based on selection

If (DD1.value ==1)

{
PCMS1.display = display.visible

break;

}

-----------------

Ive worked with VBA and many different types of Pseudocode, but this is my first time working with JavaScript. Any and all help would be extremely appreciated. 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
July 22, 2021

 JS is case-sensitive. So it's "if", not "If". Plus, the break command does not apply in an if-statement, only in a loop.

And you didn't include a condition to make the field hidden again, so it will only work once. Use Nesa's code from above, instead.

Nesa Nurani
Community Expert
Community Expert
July 22, 2021

Try like this:

var DD1 = this.getField("TCE1").value;
var PCMS1 = this.getField("PCMS1");
if (DD1 ==1)
PCMS1.display = display.visible;
else PCMS1.display=display.hidden;