Skip to main content
Participant
December 5, 2023
Question

Adobe Acrobat PDF Form - If and Then Statement

  • December 5, 2023
  • 1 reply
  • 584 views

Apologies, I'm not sure my terminology is correct here - I have my learners hat on!

I've created a pdf form with drop down boxes where I can select information.

 

I would love to set up the form so that if I chose a name in the drop down box then other information is populated accordingly.

 

Eg if I chose an employee name in one section, their email address comes up in another.

 

Any help is greatly appreciated! 

This topic has been closed for replies.

1 reply

Zara@WorkAuthor
Participant
December 5, 2023

I figured it out! For the sake of anyone else looking in the future, I set up dropdown box that was visable but doesn't print, and added all the employees initials to it.

 

I then used the following script for each area of the form I wanted auto updated (employee number, email address, full name, etc) which I added to the Calculate tab under Custom Calculation Script:

 

var drop = this.getField("Employee").valueAsString;
if(drop == "AM"){
event.value = "text1";}
else if(drop == "DM"){
event.value = "text2";}
else if(drop == "KH"){
event.value = "text3";}
else if(drop == "MS"){
event.value = "text4";}
if(drop == "PM"){
event.value = "text5";}
else if(drop == "SK"){
event.value = "text6";}

Nesa Nurani
Community Expert
Community Expert
December 5, 2023

Instead of multiple calculation scripts, you can use one 'Validation' script in the dropdown field to populate all other fields.

var name = this.getField("Name");
var phone = this.getField("Phone");
var email = this.getField("Email");

if(event.value == "AM"){
 name.value = "name1";
 phone.value = "phone1";
 email.value = "email1";}
else if(event.value == "DM"){
 name.value = "name2";
 phone.value = "phone2";
 email.value = "email2";}
else if(event.value == "KH"){
 name.value = "name3";
 phone.value = "phone3";
 email.value = "email3";}
//continue with 'else if' statements if you have more names.
else{
 name.value = "";
 phone.value = "";
 email.value = "";}