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

Button to show/ hide page templates

Participant ,
Oct 06, 2023 Oct 06, 2023

I have a check box button on page 1.  The following code works to show/hide page 2 .  Click the button, show page 2.  Unclick the button, hide page 2.

 

However, it gives me a "bad parameter" despite working.  Any ideas?

 

if(event.target.value!="Off")
{this.getTemplate("2" ).hidden=false;}
else
{this.getTemplate("2" ).hidden=true;}

TOPICS
Edit and convert PDFs , JavaScript , Modern Acrobat , PDF , PDF forms
6.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 ,
Oct 06, 2023 Oct 06, 2023

Ok the target page isn't set. That is the source of the error.   Page numbers in the Acrobat JavaScript model are zero based. Page #1 is 0, and Page #2 is 1;

 

Use this code:

if(event.target.value!="Off")
{this.getTemplate("2" ).spawn(1, false, false);}
else
{this.deletePages(1);}

 

 

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 ,
Oct 13, 2023 Oct 13, 2023

I deleted the zoom action and I'm not seeing any errors. Could be there is a timing issue on your system. Or the problem was that the check box wasn't synchronized with the template. 

One other improvement.  There is no need to have 3 separate JS actions. The code should be combined into a single action. 

 

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
Participant ,
Oct 16, 2023 Oct 16, 2023
LATEST

Interesting.  Well thanks for helping me work through this!

 

I will combine all the JS actions into one too.

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