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

Deleting pages with javascript

Explorer ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

I want to delete pages if value is 0, but it delet another pages and only one page, there is somthing that I don't understand

var fx5 = this.getField("avgCbitq5");
var fx6 = this.getField("avgCbitq6"); 
var fx7 = this.getField("avgCbitq7");

if (fx5.value == "0"){
this.deletePages(12); 
}

else if (fx6.value == "0"){
this.deletePages(13); 
}

else if (fx7.value == "0"){
this.deletePages(14); 
}
TOPICS
PDF forms

Views

3.1K

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 , Aug 31, 2020 Aug 31, 2020

You can do it like this:

 

if (this.getField("fieldA").valueAsString=="0") this.deletePages(this.getField("fieldA").page);

if (this.getField("fieldB").valueAsString=="0") this.deletePages(this.getField("fieldB").page);

etc.

 

That way you're not using the actual page numbers, but the ones the fields are on, so you don't need to do it in reverse or hard-code the numbers into your code.

Votes

Translate

Translate
Community Expert ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

What pages want you delete?

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 ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

I want to delet page 13, 14 and 15

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 ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

OK

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
LEGEND ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

Hmm, I'd expect this to delete one of pages 13 or 14 or 15 

or two of 13,16 or 14,16 or 13,15

or all three of 13,15,17

I didn't carefully check. Is that really what you want?

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 ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

I want to delet page 13, 14 and 15. I added this code in AutoMailMerge to excute this script.

 

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 ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

What's your question, then? Your code does that. Does it not work correctly? If so, what happens when you use it?

Also, where did you place it?

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 ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

I want to delet page 13, 14 and 15. I added this code in AutoMailMerge to excute this script at the end. But it delets only one page page#(14). I know that pages start's at #Zero in the code. 
What I want is to delete pages if a certian value is 0 but it didn't work at all as I want. 

 

In this scenario it should delete 3 pages but it didn't work.  

Executed PDF 

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 ,
Aug 20, 2020 Aug 20, 2020

Copy link to clipboard

Copied

The document doesn't have any form field. Where does you use your script? Why does you use a if-else structure?

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 ,
Aug 20, 2020 Aug 20, 2020

Copy link to clipboard

Copied

If you want to delete all three pages then you should do it either in a single command, or in reverse order, because when you delete page 13 what was before page 14 is now page 13, not 14, and the same for all other pages that follow it.

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 ,
Aug 23, 2020 Aug 23, 2020

Copy link to clipboard

Copied

I lattely tried to do it but it's not working at all

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 ,
Aug 23, 2020 Aug 23, 2020

Copy link to clipboard

Copied

You need to provide more information if you want help...

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Okay : ) simply I need a script to check filed value, if this value == 0 then delete this page. I want to repeat it to all pages.
For example: page#1 contains fieldA if it's value equals to 0 then delete it, then in page#2 if fieldB value equals to 1 then don't delete it. I have 18 pages each page contains different fields.

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

You can do it like this:

 

if (this.getField("fieldA").valueAsString=="0") this.deletePages(this.getField("fieldA").page);

if (this.getField("fieldB").valueAsString=="0") this.deletePages(this.getField("fieldB").page);

etc.

 

That way you're not using the actual page numbers, but the ones the fields are on, so you don't need to do it in reverse or hard-code the numbers into your code.

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

LATEST

WOOOOW! You saved my life. Thanks very much for your time.

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