Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

TextFields: saving user input as variable to populate other fields

Avatar

Level 3

Hi,

For a complex form project, I am first trying to create a basic "proof of concept" form: in the complex project, the user will enter data in several TextFields and depending on what is entered, this will make visible further TextFields to be completed or TextFields which will need to be populated with the data that the user enters.

But as a novice using Designer ES2, I need to see if I can first create some basic functionality in a "proof of concept" form. First: to be able to set up TextField1 on page 1 to capture the user's first name which can then be displayed in additional TextFields on pgaes 2-6 (for "proof of concept" purposes, it would be helpful to have the user's entered first name display in TextField2 on page 2). I've been stuck trying to get this to work, not sure what JavaScript will save the entered first name in TextField1 and then populate it into TextField2 on page 2? Which event to use to get it to show on page 2? (Can't use Binding to Global variables with TextFields having same Data Binding name in the more complex project, so need to try to achieve this by scripting only.)

Any help with this "proof of concept" scripting would be appreciated.

Regards,

saratogacoach

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi,

You have the following code

page2.form1.#subform[1].TextField5.rawValue = page1.form1.#subform[0].TextField1.rawValue;

if you change this to

TextField5.rawValue = TextField1.rawValue;

Then it should work in the layout of the form you have at the moment.

Hope this helps

Malcolm

View solution in original post

8 Replies

Avatar

Level 10

You always use the rawValue to assign a value to a field in the form. The field can be anywhere in the form (means any page).

The only thing you need to mention is the path of the field in the expression.

//For example you want to populate TextField2 in Subform2 inside Page2 with the data from TextField1 in Subform1 inside Page1. You can assign the same value to different fields in multiple pages.

Page2.Subform2.TextField2.rawValue = Page1.Subform1.TextField1.rawValue;

Page6.Subform6.TextField6.rawValue = Page1.Subform1.TextField1.rawValue;

Thanks

Srini

Avatar

Level 3

Hi Srini,

Thank you for your reply and suggestions. Unfortunately, as a beginner, I'm not sure where to even place the script: change event for TextField1 on page1, or a different event on a different page? A sample would be to script so that user enetered first name in TextField1 on page 1 populates TextField2 on page 2.

Not sure how to do this.

Regards,

saratogacoach

Avatar

Level 10

Place the script in the Exit event of the TextField1 field in Page1 with JavaScript as language.

In the sample script I gave you above, you need to replace with the correct path of the field.

Check your heirarchy/ First line in your Script Editor when you choose any event, to get the correct path of the field.

<PageName><SubformName><FieldName>.rawValue

Thanks

Srini

Avatar

Level 3

Hi Srini,

Tried these suggestions, but still does not work. I must still be doing something wrong.

I am posting the sample form at: www.elearningprojects.com/sampleform1.pdf

If possible, please take a look and suggest a way to get it working.

Thank you for your help.

saratogacoach

Avatar

Correct answer by
Level 5

Hi,

You have the following code

page2.form1.#subform[1].TextField5.rawValue = page1.form1.#subform[0].TextField1.rawValue;

if you change this to

TextField5.rawValue = TextField1.rawValue;

Then it should work in the layout of the form you have at the moment.

Hope this helps

Malcolm

Avatar

Level 3

Thanks Malcolm.

And thanks again to Srini.

That worked. Now to build the "proof of concept" sample form further...

Regards,

saratogacoach

Avatar

Level 10

Here is the corrected form..

https://acrobat.com/#d=*ua*KZ-kd4Nqdu64Jc98jA

Look at the Heirarchy that I have given proper name to Page1 and Page2.

Thanks

Srini

Avatar

Level 3

Thanks again, Srini.

The hierarchy renaming is much better. I suspect that it is very important to build a form like this on a "solid foundation" using correct hierarchy and naming.

Regards,

saratogacoach