Copy link to clipboard
Copied
I am trying to figure out the correct Javascript to accomplish a certain action within my Adobe PDF. Here's a quick summary:
Field 1 is a dropdown menu containing 2 options. These options are "Arlington" and "Beverly Hills"
Field 2 needs to populate with the value of 1000 if Arlington is selected or a value of 1500 if Beverly Hills is selected
Can anyone help me with creating the javascript for this?
Thank you,
Matt
Ah, OK, then you can use something like this:
var v = this.getField("Field 1").valueAsString;
if (v=="Arlington") event.value = 1000;
else if (v=="Beverly Hills") event.value = 1500; // etc.
else event.value = "";
Copy link to clipboard
Copied
Apply those values as the export values of the items in the drop-down field and then use this code as the custom calculation script of the text field:
event.value = this.getField("Dropdown1").value;
Replace "Dropdown1" with the actual field name, of course.
Copy link to clipboard
Copied
So I may have made my question too simple. I will actually have Field 2, Field 3, and Field 4 populating with their own unique value based on the selection made in Field 1. So I don't believe a single export value will work in this case.
Here's an example of my final product:
Field 1: Arlington
Field 2: Populates with 1000 because Arlington was selected
Field 3: Populates with 1200 because Arlington was selected
Field 4: Populates with 1400 because Arlington was selected
Fields 2-4 would populate with different values if Beverly Hills is selected.
In case it matters my dropdown menu actually has about 20 options and each option will need to populate fields 2-4 differently. I figured if I can get it working with just 2 options then I could figure out how to expand it to cover more options.
Copy link to clipboard
Copied
Ah, OK, then you can use something like this:
var v = this.getField("Field 1").valueAsString;
if (v=="Arlington") event.value = 1000;
else if (v=="Beverly Hills") event.value = 1500; // etc.
else event.value = "";
Copy link to clipboard
Copied
This worked perfectly, thank you so much for your assistance try67! You're awesome!
Matt
Find more inspiration, events, and resources on the new Adobe Community
Explore Now