These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Merging text fields

dunlops
Registered: Apr 6 2010
Posts: 3
Answered

I am very new to Acrobat. I've search high and low on the forums for an answer before posting. There seem to be some answers, but they have not worked when I tried them.

I'm using Acrobat 9. I have a document that is several pages long. On the very first page, I have client data that is separated into fields.

ie. "First Name" "Last Name"

After page one, I need to be able to merge the data from those two above mentioned fields to create a text field "Complete Name". Otherwise, my form and therefore my client documentation looks horrible.

I do not quite understand where to go once I open up the "Text Field Properties" dialogue box.

Do I go to validate or calculate? What do I enter from there?

Thanks in advance for any help.

My Product Information:
Acrobat Standard 9.3.1, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
There are a number of places that the code could be placed, and the choice of placement on a large form can impact the performance.

But first, in Acrobat the "+" operator will add numbers or concatenate character strings. And how it works depends upon what Acrobat JavaScript thinks one wants to do. But you can force the appropriate action by using either the JavaScript 'Number(value)' to force a value to a number or the "String(value)' constrictor, 'toString()' method, or 'valueAsString to force a value to a string. So now we have a method to force the '+' to act as the concatenation operator.

One could use the 'calculate' action of the filed for the combined value, but this action will execute every time any field that is used in a calculation is updated, and in a long form this will impact performance. But one has a number of other field actions. The 'On Blur' executes only when a field loses focus or one leaves the field by tabbing or using the mouse. So this action for the first name and last name field would provide a more efficient approach, as the script would only run twice.
// for first name// get first name as a stringvar sFirst = event.value.toString();// get last name as a stringvar sLast = this.getField("Last Name").valueAsString;// define an option separatorvar sSpace = ''; // empty string// if first name make separator a spaceif(sFirst != '') sSpace = ' ';// combine the names with necessary separatorthis.getField("Complete Name").value = sFirst + sSpace + sLast;

// for last name// get first name as a stringvar sFirst = this.getField("First Name").valueAsString;// get last name as a stringvar sLast = event.value.toString();// define an option separatorvar sSpace = ''; // empty string// if first name make separator a spaceif(sFirst != '') sSpace = ' ';// combine the names with necessary separatorthis.getField("Complete Name").value = sFirst + sSpace + sLast;

George Kaiser

dunlops
Registered: Apr 6 2010
Posts: 3
Thanks!