Skip to main content
Participant
May 20, 2019
Question

How to run if statements with drop down menu.

  • May 20, 2019
  • 1 reply
  • 560 views

Hello, so I am new to Acrobat and I have figured out how to do this with checkboxes, but I am trying to do it with a drop-down menu.

Ex:

     You have drop menu called Drop1. in Drop1 you have item1, item2, item3.

      If user select item1, a hidden pop-up box will appear on Screen saying "You have selected Item 1".

      If user select item2, a hidden pop-up box will appear on Screen saying "You have selected Item 2".

ect.

This is almost exactly what I need, except with a drop-down menu.

Acrobat XI Tutorial Showing Form Fields Based on a Checkbox - YouTube

I do know c++ programming, so I know a little bit about programming, but I believe this is java.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 20, 2019

It's pretty much the same, just access the valueAsString property of the field to get the currently selected value.

Participant
May 20, 2019

okay so I’m not very familiar with Java, could i possible get the code for that.

Ex: you have Drop1, and Text1. In Drop1 you have options 1,2,3. I only want Text1 showing up when 2 and or 3 are selected.

the Only thing confusing to me is how I’m accessing those Value Making it appear or disappear based on the selection

try67
Community Expert
Community Expert
May 20, 2019

First of all, it's JavaScript, not Java.

OK, to do that you can use the following code as the custom validation script of "Drop1":

var showField = (event.value=="2" || event.value=="3");

this.getField("Text1").display = showField ? display.visible : display.hidden;

The second line is a form of if-condition, and can be replaced by this:

if (showField==true) {

     this.getField("Text1").display = display.visible;

} else {

     this.getField("Text1").display = display.hidden;

}

Make sure to tick the option to commit the selected value of the drop-down field immediately if you want it to work as soon as you make the selection (under the field's Properties, Options tab).