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

Can't access textfield value from another page

Avatar

Level 1

Hello there, I thought this would be straight forward and simple, but I have hit a wall.

I cant seem to access values from another page in a script.

I'm trying to set a value of a text field to the value of a text field that is in another page.

On the click event(just for testing) I have:

eApp.ENB-7-07-CAGAIN_Page_5.a3z_data_AdditionalInfo::click - (JavaScript, client)

this.rawValue =  eApp.ENB-7-07-CAGAIN_Page_4.AccountNumber.rawValue;

It doesnt get the value.

But if i copy create a field on the same page(page 5 here) with the same info, I can access

with this.parent.AccountNumber.rawValue;

I can get it to work, by copying the textfields to the page and hiding them, then using their value,

but this seems messy and unnecessary.

I just want to be able to access fields on another page, I would have thought it would be as easy as form.page4.accessthisvalue

Any help is DEEPLY appreciated, been banging my head for a loong time.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

There should not be a problem doing this, you can reference a field anywhere on the form.  Are you getting any script errors?  My first guess would be to rename the field ENB-7-07-CAGAIN_Page_4 so that it does not have the hyphen character in it, it might be trying to subtract 7 from a variable it thinks is called ENB.

Regards

Bruce

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Hi,

There should not be a problem doing this, you can reference a field anywhere on the form.  Are you getting any script errors?  My first guess would be to rename the field ENB-7-07-CAGAIN_Page_4 so that it does not have the hyphen character in it, it might be trying to subtract 7 from a variable it thinks is called ENB.

Regards

Bruce

Avatar

Level 1

Wow I am shocked, I think the - character makes it crash for some reason.

I took out the dash in the name and it worked.

Sadly I cant really remove the dashes from the final product, so need to find a way of referencing it with the dashes.

Looking into get element, not sure if it might work.

Any input is appreciated.

By the way, I appreciate the help immensely, it gave me direction and saved some of the little sanity I have left.

Avatar

Level 10

Hi,

Glad I could help,

If you can't get rid of the hyphen from the field name you could try either;

this.rawValue = eApp.resolveNode("ENB-7-07-CAGAIN_Page_4").AccountNumber.rawValue

or

this.rawValue = eApp["ENB-7-07-CAGAIN_Page_4"].AccountNumber.rawValue

You can also change the binding name so the XML still comes out with a hyphen but the field name uses something else.

Regards

Bruce