Skip to main content
Inspiring
June 30, 2020
Answered

'check all checkbox' not working on spawned pages

  • June 30, 2020
  • 3 replies
  • 1507 views

I have created a form with page templates that spawn when a checkbox is checked on p1.

One of the page templates has a list of checkbox options, with a 'select all' checkbox, which checks all checkboxes in the list.

When the page is spawned, it loses the functionality of 'select all'.

How can I ensure that the 'select all' checkbox links to the other checkboxes on it's spawned page?

So far I have:

   if(event.target.isBoxChecked(0))

   {// Perform actions when checked

      this.getField("option1").checkThisBox(0,true);

      this.getField("option2").checkThisBox(0,true);

      this.getField("option3").checkThisBox(0,true);

   else

   {// Perform actions when unchecked

    this.getField("option1").checkThisBox(0,false);

      this.getField("option2").checkThisBox(0,false);

      this.getField("option3").checkThisBox(0,false);

   }

This works on the Page Template, but loses it's functionality on spawned pages.

I'd love some help - I think I need to include a reference within the script that includes the current page number and template name, before each 'this.getField("option3").checkThisBox(0,false);'

Thanks.

This topic has been closed for replies.
Correct answer cath.g

Thanks all for your input.

I found a thread which works perfectly: 

 

 

var cPreFix = "";
// get prefix elements for spawned pages;
var aFieldName = event.target.name.split(".");
if(aFieldName.length > 2)
{
// first 2 elements of name array makeup the prefix for fields on a spawned page;
cPreFix = aFieldName[0] + "." + aFieldName[1] + ".";
}
//if/else conditional statement
if(event.target.isBoxChecked(0))
{// Perform actions when checked
   this.getField(cPreFix +"Option1").checkThisBox(0,true);
   this.getField(cPreFix +"Option2").checkThisBox(0,true);
   this.getField(cPreFix +"Option3").checkThisBox(0,true);

else
{// Perform actions when unchecked
    this.getField(cPreFix +"Option1").checkThisBox(0,false);
   this.getField(cPreFix +"Option2").checkThisBox(0,false);
   this.getField(cPreFix +"Option3").checkThisBox(0,false);
}

 

 

 

 

Thanks to gkaiseril from the adobe community forums :

acrobat/how-do-i-have-calculated-scripts-adjust-when-i-spawn-a-new-page-from-a-template/

[https://community.adobe.com/t5/acrobat/how-do-i-have-calculated-scripts-adjust-when-i-spawn-a-new-page-from-a-template/m-p/9902135?page=1]

3 replies

cath.gAuthorCorrect answer
Inspiring
July 3, 2020

Thanks all for your input.

I found a thread which works perfectly: 

 

 

var cPreFix = "";
// get prefix elements for spawned pages;
var aFieldName = event.target.name.split(".");
if(aFieldName.length > 2)
{
// first 2 elements of name array makeup the prefix for fields on a spawned page;
cPreFix = aFieldName[0] + "." + aFieldName[1] + ".";
}
//if/else conditional statement
if(event.target.isBoxChecked(0))
{// Perform actions when checked
   this.getField(cPreFix +"Option1").checkThisBox(0,true);
   this.getField(cPreFix +"Option2").checkThisBox(0,true);
   this.getField(cPreFix +"Option3").checkThisBox(0,true);

else
{// Perform actions when unchecked
    this.getField(cPreFix +"Option1").checkThisBox(0,false);
   this.getField(cPreFix +"Option2").checkThisBox(0,false);
   this.getField(cPreFix +"Option3").checkThisBox(0,false);
}

 

 

 

 

Thanks to gkaiseril from the adobe community forums :

acrobat/how-do-i-have-calculated-scripts-adjust-when-i-spawn-a-new-page-from-a-template/

[https://community.adobe.com/t5/acrobat/how-do-i-have-calculated-scripts-adjust-when-i-spawn-a-new-page-from-a-template/m-p/9902135?page=1]

try67
Community Expert
Community Expert
June 30, 2020

As mentioned, the fields are probably renamed. You can disable that and use the same code, but then those fields will be copied of the ones on the original page. If you do want them to be unique then you'll need to adjust your code. Luckily, the names of the fields on the spawned pages are predictable so it is possible to locate all of the fields that match a certain pattern using a script.

cath.gAuthor
Inspiring
July 1, 2020

Thanks for the responses, but I need the spawned pages' fields to rename, as the page template may be spawned more than once, with each new spawned page requiring different input.

I understand that this will need script, but that's where I get lost, as a newbie to scripting. I guess I need the script to return the current page number and Page Template?

So far I have:

   if(event.target.isBoxChecked(0))

   {// Perform actions when checked

      this.getField("option1").checkThisBox(0,true);

      this.getField("option2").checkThisBox(0,true);

      this.getField("option3").checkThisBox(0,true);

   else

   {// Perform actions when unchecked

    this.getField("option1").checkThisBox(0,false);

      this.getField("option2").checkThisBox(0,false);

      this.getField("option3").checkThisBox(0,false);

   }

This works on the Page Template, but loses it's functionality on spawned pages.

I have tried to add various code, eg: 'this.get.page.pageTemplate' before 'option1, 2, 3' etc. but no luck.

I would appreciate any help you may have to offer. 

Bernd Alheit
Community Expert
Community Expert
July 1, 2020

With event.target.name you will get the name of the checkbox on the spawned page.

JR Boulay
Community Expert
Community Expert
June 30, 2020

I guess this is because form fields are renamed (by default) when a page is spawned.

This can be set using the bRename parameter: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJS/Template_methods.htm?rhhlterm=brename&rhsyns=%20

Acrobate du PDF, InDesigner et Photoshopographe