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

Deleting Spawned Pages

Community Beginner ,
Jan 23, 2021 Jan 23, 2021

Copy link to clipboard

Copied

Hi all

 

I am working on a form in Acrobat. It is a training form with Competent/Not Yet Competent (C/NYC). The form will auto select C/NYC depending on the checkbox selections. If they are Not Yet Competent then two pages will spawn for the reassessment component. These forms  are hidden at the start.

 

For Competent the script will delete the last two pages. As these pages are hidden at the start and iff the person is assessed as Competent at the start the calculate script runs but stops at the deletepages part of the script and won't proceed.

 

Is there a way for this delete script to take into account the pages may or may not be there. The script I'm using is as follows:

 

if (this.getField("Check Box1").value == "Yes"

    && this.getField("Check Box2").value == "Yes"

    && this.getField("Check Box3").value == "Yes"

    && this.getField("Check Box4").value == "Yes"

    && this.getField("Check Box5").value == "Yes"

    && this.getField("Check Box6").value == "Yes"

    && this.getField("Check Box7").value == "Yes" ) {

    this.getField("ResultCB").value = "Yes";

    this.deletePages({nStart: 5, nEnd: 6 });

    }

 

Any assistance is appreciated.

 

Gary

 

TOPICS
JavaScript , PDF forms

Views

577

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 , Jan 25, 2021 Jan 25, 2021

Yes, add it before:

this.deletePages({nStart: 5, nEnd: 6 });

Like this:

if (this.numPages>=7) this.deletePages({nStart: 5, nEnd: 6 });

 

Votes

Translate

Translate
Community Expert ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

You can check the number of pages in the file before deleting them. If the number is less than 7, don't proceed.

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
Community Beginner ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

try

 

How would I do that? I am not well versed in Javascript.

 

Gary

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
Community Expert ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

Add this to the if condition:

if (this.numPages>=7 && ...

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
Community Beginner ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

try

 

Where would I place that in the script provided? If I place it at the start then line 8 of the script won't occur if >=7. Is that correct?

 

Gary

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
Community Expert ,
Jan 25, 2021 Jan 25, 2021

Copy link to clipboard

Copied

Yes, add it before:

this.deletePages({nStart: 5, nEnd: 6 });

Like this:

if (this.numPages>=7) this.deletePages({nStart: 5, nEnd: 6 });

 

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
Community Beginner ,
Jan 25, 2021 Jan 25, 2021

Copy link to clipboard

Copied

LATEST

Worked a treat. Thank you.

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