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

If statement selection with a predefined result in Acrobat DC

Community Beginner ,
Nov 04, 2018 Nov 04, 2018

Copy link to clipboard

Copied

Hi All,

I'm in Acrobat DC and I want to have a javascript with an If statement to do the following task. I know I'll need a if statement but I need some help starting it off.

I have a two drop down fields. First down I have PointA, PointB and PointC  and Second drop down I have the same PointA, PointB and PointC. Now I have my Third Field box as a number because if I want to select PointA on the first drop down and select PointC on the second drop down then I want my Third field box to have a 4 for distance.

So I already know this much

PointA to PointB= 3 miles

PointA to PointC= 4 miles

PointB to PointC=5 miles

And these miles will not change because they are already calculated.

thanks in advance

TOPICS
Acrobat SDK and JavaScript , Windows

Views

149

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
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 04, 2018 Nov 04, 2018

You can use this code as the custom calculation script of your text field (adjust the field names in the first two lines to match the actual names in your file):

var v1 = this.getField("Dropdown1").valueAsString;

var v2 = this.getField("Dropdown2").valueAsString;

if (v1=="PointA" && v2=="PointB") event.value = 3;

else if (v1=="PointA" && v2=="PointC") event.value = 4;

else if (v1=="PointB" && v2=="PointC") event.value = 5;

else event.value = "";

Edit: fixed a small mistake in line #5.

Likes

Translate

Translate
Community Expert ,
Nov 04, 2018 Nov 04, 2018

Copy link to clipboard

Copied

LATEST

You can use this code as the custom calculation script of your text field (adjust the field names in the first two lines to match the actual names in your file):

var v1 = this.getField("Dropdown1").valueAsString;

var v2 = this.getField("Dropdown2").valueAsString;

if (v1=="PointA" && v2=="PointB") event.value = 3;

else if (v1=="PointA" && v2=="PointC") event.value = 4;

else if (v1=="PointB" && v2=="PointC") event.value = 5;

else event.value = "";

Edit: fixed a small mistake in line #5.

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
community guidelines