Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Field Calculations - Duplication of Text

Avatar

Former Community Member

Help Please,

I have created TextBox1 and TextBox2. I want whatever is entered into TextBox1 to automaticall fill into TextBox 2. I have done this 1,000 times before but now get a weird result. In TextBox2, under Calculated, at Client, I enter TextBox2=TextBox1. I have tried this in both JavaScript and FormCalc. I have also reversed them, TextBox1=TextBox2. Either way I do it, the result that fills into TextBox 2 is "Object" and then some numbers. What is this, and what am I doing to create it?

Any help is appreciated!!!

Gene-O

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

The Object1234565 is assigning the Textbox1 object to the value of Textbox2.

The following would be in the calculate event of Textbox2.

Using javascript:

this.rawValue = Textbox1.rawValue; 

Using FormCalc:

$ = Textbox1

You may want to wrap this in an if statement to first check that Textbox1 is not null.

The other way to achieve this would be to give Textbox1 and Textbox2 the same name and then set their binding to Global in the Object/Binding tab.

Hope that helps,

Niall

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

Hi,

The Object1234565 is assigning the Textbox1 object to the value of Textbox2.

The following would be in the calculate event of Textbox2.

Using javascript:

this.rawValue = Textbox1.rawValue; 

Using FormCalc:

$ = Textbox1

You may want to wrap this in an if statement to first check that Textbox1 is not null.

The other way to achieve this would be to give Textbox1 and Textbox2 the same name and then set their binding to Global in the Object/Binding tab.

Hope that helps,

Niall

Avatar

Former Community Member

Your answer worked!! Thanks so much. So I don't do this again, why did TextBox2 put that "Object1234" value in there?

I want to know how I created that, so I don't repeat it.

Thanks again!!!!!

Avatar

Level 10

Hi,

This can happen when your script is saying "make this object the same as the object on the left". When what you want to say is "make the value of this object the same as the value of the object on the left.

When using Javascript you should use .rawValue after the object name. I believe that the FormCalc syntax does not require this; however I have seen other people using it in FormCalc also.

If you are referencing a global variable you would use .value.

See attached, which shows "Object82249996".

Good luck,

Niall