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

How to run if statements with drop down menu.

New Here ,
May 19, 2019 May 19, 2019

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

290

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 ,
May 20, 2019 May 20, 2019

Copy link to clipboard

Copied

It's pretty much the same, just access the valueAsString property of the field to get the currently selected 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
New Here ,
May 20, 2019 May 20, 2019

Copy link to clipboard

Copied

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

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 ,
May 20, 2019 May 20, 2019

Copy link to clipboard

Copied

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).

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 ,
May 20, 2019 May 20, 2019

Copy link to clipboard

Copied

Yeah my bad, I just realized I was saying java. Okay cool, I’ll give that a shot in the morning! Thank you.

just to clarify, the second line for the if state, its just stating if true, display message, else hide message. correct?

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 ,
May 20, 2019 May 20, 2019

Copy link to clipboard

Copied

LATEST

If by "message" you mean field, then yes.

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