Expand my Community achievements bar.

SOLVED

How to reference JavaScript functions stored in a script object on a different page?

Avatar

Former Community Member

Hi,

I have a form which has 2 pages. I have a bunch of JavaScript functions under script objects on page 1. How can I access these functions from page 2?

I tried the following but none of it work:

form1.page2.#variables[0].testScript.doThisNow();

form1.page2.variables[0].testScript.doThisNow();

form1.page2.variables.testScript.doThisNow();

Please help.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Simplest way would be to drag the script object to be under the root node (form1). On both pages would would then be able to reference the function by:

testScript.doThisNow(); 

If you leave the script object under page1, then from page2, the following should work:

page1.testScript.doThisNow(); 

Hope that helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

Simplest way would be to drag the script object to be under the root node (form1). On both pages would would then be able to reference the function by:

testScript.doThisNow(); 

If you leave the script object under page1, then from page2, the following should work:

page1.testScript.doThisNow(); 

Hope that helps,

Niall