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

How to populate a field from multiple other fields?

New Here ,
Jul 14, 2021 Jul 14, 2021

I have a form with 2 pages. On page 1, there's a field for First Name, a field for Middle Initial, and a field for Last Name. On page 2, there's a field for "First Name, Middle Initial, Last Name". If someone has already filled out the 3 fields on page 1, I want it to populate into the field on page 2. Also, since some people don't have middle initials I want an "if" statement for if the MI field is empty on page 1 so that it doesn't try to include that value on page 2.

 

How can I do this? I'm assuming it's a validation script but I don't know on which field to enter the script and what script I would put. Thanks in advance.

TOPICS
Create PDFs , JavaScript , PDF forms
1.6K
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 ,
Jul 14, 2021 Jul 14, 2021

As custom calculation script of field on 2nd page use this:

var fn = this.getField("First Name").valueAsString;
var mn = this.getField("Middle Initial").valueAsString;
var ln = this.getField("Last Name").valueAsString;
if(fn != "" && mn == "" && ln != "") event.value = fn+" "+ln;
else if(fn != "" && mn != "" && ln != "")event.value = fn+" "+mn+" "+ln;
else event.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 ,
Jul 14, 2021 Jul 14, 2021

If I understand you right, you don't need script for this, just name fields on 2nd page same as  fields on 1st page. Whatever you write in fields on 1st page it will be on 2nd page also.

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
New Here ,
Jul 14, 2021 Jul 14, 2021

The problem is, on page one the items are broken into 3 different field ("First Name", "Middle Initial", "Last Name").

On page 2, there is 1 field with all 3 of those items ("First Name, Middle Initial, Last Name"). I want to populate the form on page 2 by combining the 3 different fields from page 1.

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 ,
Jul 14, 2021 Jul 14, 2021

As custom calculation script of field on 2nd page use this:

var fn = this.getField("First Name").valueAsString;
var mn = this.getField("Middle Initial").valueAsString;
var ln = this.getField("Last Name").valueAsString;
if(fn != "" && mn == "" && ln != "") event.value = fn+" "+ln;
else if(fn != "" && mn != "" && ln != "")event.value = fn+" "+mn+" "+ln;
else event.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
New Here ,
Jul 14, 2021 Jul 14, 2021
LATEST

That did it! Thank you!

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