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
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.
Copy link to clipboard
Copied
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.