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

Button to show/ hide page templates

Explorer ,
Oct 06, 2023 Oct 06, 2023

Copy link to clipboard

Copied

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

Views

3.7K

Translate

Translate

Report

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

correct answers 1 Correct answer

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

 

 

Votes

Translate

Translate
Community Expert ,
Oct 13, 2023 Oct 13, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Interesting.  Well thanks for helping me work through this!

 

I will combine all the JS actions into one too.

Votes

Translate

Translate

Report

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