Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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, " ");
Copy link to clipboard
Copied
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, " ");
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Same script as above, just adjust the field names as needed. It doesn't matter that they are on different pages.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Use this:
event.value = this.getField("Name").valueAsString + " " + this.getField("Last").valueAsString;
Copy link to clipboard
Copied
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???
Copy link to clipboard
Copied
Calculate, then Custom Calculation Script.
Copy link to clipboard
Copied
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.