Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

PDF Form spawned page reset fields only on spawned page

Community Beginner ,
Nov 16, 2021 Nov 16, 2021

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! 

TOPICS
PDF forms
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Nov 16, 2021 Nov 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2021 Nov 16, 2021

Have you renamed the form fields on the spawned page?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 16, 2021 Nov 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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2021 Nov 16, 2021

Why does you use this form field names on the template page? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 16, 2021 Nov 16, 2021

I read on another forum page that you should rename hidden template fields to the "P0..." format.  Was this not correct?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2021 Nov 16, 2021

Yes 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2021 Nov 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2021 Nov 22, 2021

Thom, thank you so much!  Works perfectly 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2021 Nov 22, 2021

You're welcome!  A best Answer would be helpful. 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2021 Nov 22, 2021

My apologies, I clicked the wrong one!  Fixed now.  Thanks again 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 25, 2022 Apr 25, 2022
LATEST

Thom this worked beautifully for the single page form that I needed to spawn from a template and clear the fields. Can you share how this would work with a multipage form? I use this code to spawn the two page form: 

var expTplt = getTemplate("CIP1") ; expTplt.spawn(pageNum+1,true,false) ;

var expTplt = getTemplate("CIP2") ; expTplt.spawn(pageNum+1,true,false) ;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines