How do I auto-populate several text fields from a single dropdown selection?

New Here ,
Apr 21, 2022 Apr 21, 2022

Copy link to clipboard

Copied

Hi all, I've seen this question asked (and answered in different ways) many times, but none of the answers provided seem to match what I'm looking to complete. I'm working in Acrobat Pro DC. 

 

I think what I'm asking for is a simple validation script, but I can't seem to find the correct combination of code.

 

My form includes: Name (which is a dropdown box, pre-populated with names). When the Name is selected from the dropdown box, I would like the Email and Phone Number fields to also auto-populate. 

 

Drop_Name: Peter Pan

Text_Email: [Removed by MOD]

Text_Phone: [Removed by MOD]

 

Also, one of the Name selections in Drop_Name is "Other". When "Other" is selected from the dropdown menu, the Text_Email and Text_Phone fields need to be free-form text fields (so the data can be manually populated). Is there a way to complete both asks with one code/script?

 

TOPICS
Edit and convert PDFs , General troubleshooting , How to , JavaScript , PDF forms

Views

141

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

Adobe Community Professional , Apr 21, 2022 Apr 21, 2022

Hi,

 

Assuming your field names as are you mentioned, then yes you could have a validation script that goes something like:

 

var emailText = "";
var phoneText = "";

if ( event.value == "Peter Pan"){
emailText = "peter.pan@example.com";
phoneText = "+01010101001"
// just add the section again for each name you want.
} else if ( event.value == "Different name"){
emailText = "different.name@example.com";
phoneText = "+02020202020202";
}
// make sure the name in between the brackets matches your f
...

Likes

Translate

Translate
Adobe Community Professional ,
Apr 21, 2022 Apr 21, 2022

Copy link to clipboard

Copied

Hi,

 

Assuming your field names as are you mentioned, then yes you could have a validation script that goes something like:

 

var emailText = "";
var phoneText = "";

if ( event.value == "Peter Pan"){
emailText = "peter.pan@example.com";
phoneText = "+01010101001"
// just add the section again for each name you want.
} else if ( event.value == "Different name"){
emailText = "different.name@example.com";
phoneText = "+02020202020202";
}
// make sure the name in between the brackets matches your field names.
this.getField("Text_Email").value = emailText;
this.getField("Text_Phone").value = phoneText;

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
New Here ,
Apr 21, 2022 Apr 21, 2022

Copy link to clipboard

Copied

LATEST

Works perfectly, thanks much!

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