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

Combine 3 or more text fields into one

smilem
Registered: Apr 1 2008
Posts: 101
Answered

Hi, I need to combine 3 or more text fields into 1.

For example I have text Fields named like this on a page:

TextField1 - First Name
TextField2 - Last Name
TextField3 - Age
TextField4 - Address

TextField5 Should outpud data like this:

First Name_Last Name_Age_Address

I would like to add "Copy" button that would palce data in TextField5 into clipboard so I can pate it later.

Thanks.

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The concatenation of the fields is certainly possible. Acrobat JavaScirpt is designed to have a very small interface to the platform OS and direct access to the clipboard is not available. It could be possible through a use of a plug-in.

Back to you concatenation problem. If you just want to put the fields together you can use the FormCalc "Concat()" function. But if you need to insert a separator character between joined fields or adjust the result for missing or null data, you would need to create a script to make the necessary adjustments.

George Kaiser

smilem
Registered: Apr 1 2008
Posts: 101
gkaiseril wrote:
The concatenation of the fields is certainly possible. Acrobat JavaScirpt is designed to have a very small interface to the platform OS and direct access to the clipboard is not available. It could be possible through a use of a plug-in.Back to you concatenation problem. If you just want to put the fields together you can use the FormCalc "Concat()" function. But if you need to insert a separator character between joined fields or adjust the result for missing or null data, you would need to create a script to make the necessary adjustments.
I do not know how to write a script :(

I tried to exter this in my Textfield3 in calculate event

Concat("TextField1", "TextField2")

But the result is that I see: TextField1TextField2

entered in my TextField3, when my TextField1 and 2 are empty and if I fill them I still see the same.

I appreciate help if someone could help write the script.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Putting the field name within quoates creates a character string and not the access to the field contents. Since FormCalc and JavaScript are objet orientated languages, you need to reference the object and the property or method of the object. In FormCalc fields have a "rawValue" and "formattedVaue"

For TextField3 you can try:

Concat(TextField1.formattedValue, TextField2.formattedValue)

George Kaiser

almitche
Expert
Registered: Apr 1 2008
Posts: 41
Hey smilem,

As always with Designer there are a number of ways to do this. I'm going to show you one way, but you might need to tweak the behavior to suit your needs.

You could add the following JavaScript to the calculate event of your TextField5 field:

TextField1.rawValue + "_" + TextField2.rawValue + "_" + TextField3.rawValue + "_" + TextField4.rawValue;

What should happen when you view your form is that TextField5 will start out with one of the following values:

- null_null (meaning you have no default values set for your first 4 text fields)

- value1_value2_value3_value4 (where value = the default value for each field)


What should happen then is that once you change a field value and then move focus away from that field, either by tabbing out or clicking the mouse outside the field, the value of TextField5 should change accordingly.

For exmaple, if you have no default values set for your text fields, and you enter "Chris" for the first name, then if you tab to the last name field the value of TextField5 should be:

Chris_null_null_null


As for the Copy button, I guess it depends on where you want to "paste" the value. If you want your users to be able to paste the data in as part of entering data into another field, then I'm not sure that's possible to do programmatically. I don't know of any Designer or Acrobat scripting that will save values to the clipboard.

If all you want to do is fill another field with the value of TextField5, you can reference the value of TextField5 by using the JavaScript:

TextField5.rawValue;

What you could do if you want to create a copy button is try the following:

- Create a new form variable to store the value you are copying.
- Create a copy button to grab the value.
- Create a Paste button to insert the value somewhere.

1) To create a new form variable, check out the Designer Help (Scripting > Scripting Using LiveCycle Designer ES > Variables > To define a text variable).Let's say you create a variable named "textValue".

2) Create a regular button for copying. Add the following JavaScript to the click event of the button:

textValue.value = TextField5.rawValue;

3) Create a regular button for pasting. This is where it is tricky. You can use an easy script to just populate a field value like:

TextField6.rawValue = textValue.value;

But that's not very interesting. I don't know that that is very helpful.

I hope at least some of this works for you.

- Alex
smilem
Registered: Apr 1 2008
Posts: 101
almitche wrote:
Hey smilem,As always with Designer there are a number of ways to do this. I'm going to show you one way, but you might need to tweak the behavior to suit your needs.

You could add the following JavaScript to the calculate event of your TextField5 field:

TextField1.rawValue + "_" + TextField2.rawValue + "_" + TextField3.rawValue + "_" + TextField4.rawValue;

What should happen when you view your form is that TextField5 will start out with one of the following values:

- null_null (meaning you have no default values set for your first 4 text fields)

- value1_value2_value3_value4 (where value = the default value for each field)


What should happen then is that once you change a field value and then move focus away from that field, either by tabbing out or clicking the mouse outside the field, the value of TextField5 should change accordingly.

For exmaple, if you have no default values set for your text fields, and you enter "Chris" for the first name, then if you tab to the last name field the value of TextField5 should be:

Chris_null_null_null


As for the Copy button, I guess it depends on where you want to "paste" the value. If you want your users to be able to paste the data in as part of entering data into another field, then I'm not sure that's possible to do programmatically. I don't know of any Designer or Acrobat scripting that will save values to the clipboard.

If all you want to do is fill another field with the value of TextField5, you can reference the value of TextField5 by using the JavaScript:

TextField5.rawValue;

What you could do if you want to create a copy button is try the following:

- Create a new form variable to store the value you are copying.
- Create a copy button to grab the value.
- Create a Paste button to insert the value somewhere.

1) To create a new form variable, check out the Designer Help (Scripting > Scripting Using LiveCycle Designer ES > Variables > To define a text variable).Let's say you create a variable named "textValue".

2) Create a regular button for copying. Add the following JavaScript to the click event of the button:

textValue.value = TextField5.rawValue;

3) Create a regular button for pasting. This is where it is tricky. You can use an easy script to just populate a field value like:

TextField6.rawValue = textValue.value;

But that's not very interesting. I don't know that that is very helpful.

I hope at least some of this works for you.

- Alex
Everything works fine, except I need to paste the data into another program like notepad. I can paste into another textbox but not another program :(

The other part is working fine. Thanks for your time.
smilem
Registered: Apr 1 2008
Posts: 101
Anyone? I need to paste the data into another program like notepad.