Skip to main content
Known Participant
November 16, 2021
Answered

PDF Form spawned page reset fields only on spawned page

  • November 16, 2021
  • 1 reply
  • 2390 views

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 has been closed for replies.
Correct answer Thom Parker

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);

 

 

 

1 reply

Bernd Alheit
Community Expert
Community Expert
November 16, 2021

Have you renamed the form fields on the spawned page?

SGL-LAuthor
Known Participant
November 16, 2021

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"

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
November 16, 2021

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