Skip to main content
Known Participant
Nov 16, 2021 1:21 PM UTC
Answered

PDF Form spawned page reset fields only on spawned page

Hi experts, trying to reset form fields but only on the spawned page using a 'button'.  Right now it resets both spawned and original page.  Thanks for any assistance! 

This topic is closed to new replies. Start a new post to keep the conversation going.
Thom Parker
Thom ParkerCorrect answer
Community Expert
Nov 16, 2021 6:28 PM UTC

In order to reset only the fields on a spawned page you need to use a script that dynamically works out the name of the fields to reset. 

 

For example. If the button is named "Reset". Then on the spawned page it will be named "P#.TemplateName.Reset".

If you were to hard code the reset field names, then you would need to run this script.

 

this.resetForm( "P#.TemplateName");

 

To generalize the code so that it works on any template page, the script needs to extract the template prefix from the name of the reset button. Like this:

 

var strPrefix = event.targetName.split(".").splice(0,2).join(".");

this.resetForm(strPrefix);

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often

10 replies

Bernd Alheit
Community Expert
Community Expert
Nov 16, 2021 2:06 PM UTC

Have you renamed the form fields on the spawned page?

Translate
SGL-LAuthor
Known Participant
Nov 16, 2021 5:54 PM UTC

Hi Bernd, yes. It is a hidden template, I had renamed all the hidden template fields to start with "P0.templatename.fieldname".  I now see on the spawned page, all fields are renamed to "P2.templatename.P0.templatename.fieldname"

Translate
Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
Nov 16, 2021 6:28 PM UTC

In order to reset only the fields on a spawned page you need to use a script that dynamically works out the name of the fields to reset. 

 

For example. If the button is named "Reset". Then on the spawned page it will be named "P#.TemplateName.Reset".

If you were to hard code the reset field names, then you would need to run this script.

 

this.resetForm( "P#.TemplateName");

 

To generalize the code so that it works on any template page, the script needs to extract the template prefix from the name of the reset button. Like this:

 

var strPrefix = event.targetName.split(".").splice(0,2).join(".");

this.resetForm(strPrefix);

 

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often