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

How to concatenate input fields in the PDF form?

Contributor ,
Apr 17, 2020 Apr 17, 2020

I know this is a very trival question. I tried the solutions presented here but it doesn't seem to work. Maybe I might have done something wrong.

What I want to combine three input fields in my PDF form into just one field..

FieldName 1 = FIRST NAME

FieldName 2 = MIDDLE NAME

FieldName 3 = LAST NAME

Where:

FIRST NAME = John

MIDDLE NAME = Wilson

LAST NAME = Smith

I wish the result in one field with result "John Wilson Smith". If the individual fields have leading or trailing black, I wish that this character be remove also.

 

Thanks in advance for the help.

 

TOPICS
How to , PDF forms
4.7K
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 ,
Apr 17, 2020 Apr 17, 2020

What do you mean by "leading or trailing black"?

 

Basically, you can do it using this code as the custom calculation script of your field:

 

event.value = (this.getField("FIRST NAME").valueAsString + " " + this.getField("MIDDLE NAME").valueAsString + " " + this.getField("LAST NAME").valueAsString).replace(/\s+/g, " ");

 

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 ,
Apr 17, 2020 Apr 17, 2020

What do you mean by "leading or trailing black"?

 

Basically, you can do it using this code as the custom calculation script of your field:

 

event.value = (this.getField("FIRST NAME").valueAsString + " " + this.getField("MIDDLE NAME").valueAsString + " " + this.getField("LAST NAME").valueAsString).replace(/\s+/g, " ");

 

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
Contributor ,
Apr 19, 2020 Apr 19, 2020

Leading or trailing blank (not black, my apology) are space before and after the input value.

I have tried the solution you have provided and it works perfectly well. Thank you.

More power to 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
New Here ,
Sep 09, 2020 Sep 09, 2020

I use a form in pdf where in one page I enter Name in first field and Last Name in 2nd field. I too need to concatenate these two fields on a several other pages - but I do not understand how to do this. I am using the Prepare Form from Adobe Acrobat Pro DC -- can someone please explain step by step how to do this? Thanks, Damaris

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 ,
Sep 09, 2020 Sep 09, 2020

Same script as above, just adjust the field names as needed. It doesn't matter that they are on different pages.

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 ,
Sep 09, 2020 Sep 09, 2020
I copied/pasted the formula - but it didn't work --- I'm not sure how to do
this -- I use it in excel with no problems -- pretty simple -- but here it
is more difficult

my field names are

"Name"
"Last"

pretty simple -- I just don't know how to write it.


Thanks for your help.

Damaris
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 ,
Sep 09, 2020 Sep 09, 2020

Use this:

event.value = this.getField("Name").valueAsString + " " + this.getField("Last").valueAsString;

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 ,
Oct 12, 2020 Oct 12, 2020

I haven't tried this yet. But I didn't want to be rude and not reply with Thank You! The truth is: I'm probably going to need a step by step ---- for instance --- after I open "the text field properties" where would I enter the code you gave me (event.value = this.getField("Name").valueAsString + " " + this.getField("Last").valueAsString;) ---- In the "calculate" and then "simplified field notation"?  See --- I don't know where to enter the code??? 

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 12, 2020 Oct 12, 2020

Calculate, then Custom Calculation Script.

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 ,
Aug 15, 2023 Aug 15, 2023
LATEST

This worked beautifully with one exception.  I have 2 forms that I combine with this calculation set on one of the forms pulling the data from the 2nd form.  Once both forms are combined and saved I have to go in to, Prepare Form, Properties, Calculate, Edit, (leaving the script you wrote in the editor box) OK, and close.  Only then will the field populate.  Can you help please.

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