Expand my Community achievements bar.

Copy text between text boxes.

Avatar

Former Community Member

I want to my text inside a text field (box), to be automatic copying to another text field, so I only need to fill in one text box.

Is it possible?

10 Replies

Avatar

Level 10

Hi,

The simplest way is to give both fields the same name and then in the Object/Binding tab set the binding to Global (eg the third example in the attached form).

The other way is to have script (either JavaScript or FormCalc) in the calculate event of the second field (eg examples 1 and 2).

The last example, may happen if you leave out the .rawValue in the javascript. Pay it no heed.

Good luck,

Niall

Avatar

Former Community Member

This has helped me out greatly.

But, what if I want to take two or three text boxes and merge them into one text box,

Also, I would like that one box (where they all merged) to be editable.

Is that possible?

Avatar

Level 7

Sure you can merge fields. Let's say you're merging field1, field2 and field3 into field4. In the validate event of field4, try this script:

if (this.rawValue == null){

     this.rawValue = field1.rawValue + " " + field2.rawValue + " " + field3.rawValue;

}

This will concatenate the other fields into 1, with spaces between the values. You need the test for null to keep the field from changing the value back if the user alters the value.

Avatar

Former Community Member

Awesome

 

But, lets say I want to merge fields but I want them to go onto different lines.

 

For instance, I have three text boxes and in each I am writing a paragraph.

I want to merge all three boxes into one text box, BUT I need it to indent each section and space out the paragraphs.

 

Is this possible?

Avatar

Former Community Member

The \n is a new line character in javascript so you could use something like this:

ResultField.rawValue = Field1.rawVlue + "\n" + Field2.rawValue + "\n" + Field3.rawValue

This wil put the value of each the 3 fields on a separate line in ResultField (assuming that ResultField is set as a multiline field).

Paul

Avatar

Former Community Member

Awesome

 

Is it possible to have it indent the paragraphs as well?

 

Also, is there a way to prevent it from saying "null" in the result field before I type something in the other fields.

 

Thanks!

Avatar

Former Community Member

You could add a series of spaces after the \n to handle the indent.

If you do not want a null to show up make the initial value a space.

Paul

Avatar

Former Community Member

Where would I put that initial space in the code?

 

I am not sure what you mean.

 

Thanks for all your help, so far.

Avatar

Former Community Member

On the field palette - under the Value tab - there is a Default field that will hold the initial value of the field.

Paul