Avatar

Level 10

Hi Rafael,

You could try a loop. This would work best if all of the pages had a common string at the start, followed by a number. E.g. page1, page2,... page99.

This way you would hide all of the pages using the loop and then re-show the appropriate page.

Then all you would need to do is change the number in the loop, which you could do using a global variable.  This would work for 25 pages:

for (var i=1; i<=25; i++)

{

     xfa.resolveNode("page" + i).presence = "hidden";

}

// then show the page you want for that button

page12.presence = "visible";

As I say you could use a global variable in the File > Form Properties > Variables tab or set up a hidden numeric field to hold the number of pages in the form. OR you could have the hide script as a function in a script object and call this from any of the buttons. This would mean that you have one hide script in one location, which will be easier to maintain.

The function in the script object (customScript) would look like this:

function hidePages()

{

     for (var i=1; i<=25; i++)

     {

          xfa.resolveNode("page" + i).presence = "hidden";

     }

}

Then the script in the click event of the button would look like this:

customScript.hidePages();

page12.presence = "visible";

Hope that helps,

Niall

Assure Dynamics