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

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

694

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 , 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
...

Votes

Translate

Translate
Community Expert ,
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;

Votes

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

Works perfectly, thanks much!

Votes

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
Explorer ,
Nov 02, 2022 Nov 02, 2022

Copy link to clipboard

Copied

Please help, it's not working for me. I need something similar, need 2 text fields to auto populate based on dropdown selection.
 
Dropdown name: Misc Lvl
Text1 Name: Misb
Text2 Name: Misb1
 
Dropdown selection have level ie, Level 1, 2 3 and so on.. The selection with auto populate text fields which will be amounts.
 
Kidnly help me

Votes

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
Explorer ,
Nov 02, 2022 Nov 02, 2022

Copy link to clipboard

Copied

LATEST

Hi. I'm building a form. 

It have 4 fields:

1. Text Field Name: Cost.

2. Text Field Name: Unit

3. Dropdown: Frequency

4. Total.

 

The dropdown have option as daily, weekly and anually. I want Total to be auto populated on the basis of dropdown selection and calculating at the same time.

 

Eg: Upon selecting daily, Total must auto calculate '(cost*unit)*365

 

Upon selecting weekly, total will be '(cost*unit)*52.

 

Please help 

 

Votes

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