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

Auto-populate text field with pre-existing text field data based on drop down selection

Community Beginner ,
Oct 07, 2021 Oct 07, 2021

Hi All,

 

I am creating a form and doing some javascripting in the back end to customise the form to our particular needs.

One section of the form is a drop down. Depending on the selection of the drop down, (labelled "Your_Service_Agreement"), I need it to auto-populate data from already existing fields into the following field (Labelled "Service_Agreement_Name").

The fields that will have the data that I need to transfer are "First_Name", "Last_Name" and "Nominee_Full_Name".

 

Any advice is greatly appreciated!

TOPICS
How to , JavaScript , PDF forms
2.3K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Oct 11, 2021 Oct 11, 2021

Use this:

switch (event.value){
case "I,":
this.getField("Service_Agreement_Name").value = this.getField("First_Name").valueAsString+" "+this.getField("Last_Name").valueAsString;
break;
case "My plan nominee,":
this.getField("Service_Agreement_Name").value = this.getField("Nominee_Full_Name").value;
break;
default:
this.getField("Service_Agreement_Name").value = "";
}

View solution in original post

Translate
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
Community Expert ,
Oct 08, 2021 Oct 08, 2021

I assume choices in dropdown are (First Name,Last Name and Full Name) if not, change script to reflect your actual choices.

Use script as validation of  dropdown field:

switch (event.value){
case "First Name":
this.getField("Service_Agreement_Name").value = this.getField("First_Name").value;
break;
case "Last Name":
this.getField("Service_Agreement_Name").value = this.getField("Last_Name").value;
break;
case "Full Name":
this.getField("Service_Agreement_Name").value = this.getField("Nominee_Full_Name").value;
break;
default:
this.getField("Service_Agreement_Name").value = "";
}

Translate
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
Community Beginner ,
Oct 11, 2021 Oct 11, 2021

Thanks for this Nesa,

 

So it's a bit of a strange one...

The options in the drop down are "I," or "My plan nominee,"

if "I," is selected in the drop down, First_Name and Last_Name need to be pulled. These are two seperate data fields, can these be merged into a single field upon calling?

if "My plan nominee," is selected, then Nominee_Full_Name needs to be pulled. Could you help with this?

Translate
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
Community Expert ,
Oct 11, 2021 Oct 11, 2021

Use this:

switch (event.value){
case "I,":
this.getField("Service_Agreement_Name").value = this.getField("First_Name").valueAsString+" "+this.getField("Last_Name").valueAsString;
break;
case "My plan nominee,":
this.getField("Service_Agreement_Name").value = this.getField("Nominee_Full_Name").value;
break;
default:
this.getField("Service_Agreement_Name").value = "";
}

Translate
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
Community Beginner ,
Oct 14, 2021 Oct 14, 2021

You are an absolute angel! Thank you so much!!!

Translate
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
Community Beginner ,
Dec 06, 2023 Dec 06, 2023

Is there a way to allow for multiple lines in the auto-population? 

Meaning, based on what's selected in the drop-down, I want a list of instructions to auto-populate in another field. I'd like to start a new line with each step instead of paragraph form.

Translate
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
Community Expert ,
Dec 06, 2023 Dec 06, 2023

Use \n for new line.

Translate
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
Community Beginner ,
Dec 06, 2023 Dec 06, 2023

It's giving me an error message. 

Kelli34070124aofh_0-1701878109596.png

 

Translate
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
Community Expert ,
Dec 06, 2023 Dec 06, 2023
LATEST

Text needs to be inside quotes. Also, you don't need a semicolon after each line of text.

Translate
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