Skip to main content
Participating Frequently
Oct 19, 2023 7:02 PM UTC
Answered

Java Script Delete Page

Hello I'm new to javascript.  I'm pretty much googling everything so if I do not use the correct nomenclature, my apologies.  I have a pdf document with a check box.  I would like this check box to spawn a "medical" form and make two fields hidden and when they uncheck the box, I would like for the "medical" form to be deleted and the two fields to be visible.  So far, I have been able to write a javascript where it does everything except for deleting the "medical" page.  No matter how I try to write the script, I can't get it to delete the "medical" form. Below is my script.  Can anyone help?

var a = this.getField("Please Answer");
var b = this.getField("Questions");
var c = this.getTemplate("Medical")

if(event.target.value == "Yes"){
a.display = display.hidden;
b.display = display.hidden;
c.spawn(event.target.page+5, false, false)
}

else if(event.target.value == "Off"){
a.display = display.visible;
b.display = display.visible;
c.deletePage({nStart: 6})
}

This topic is closed to new replies. Start a new post to keep the conversation going.
Thom Parker
Thom ParkerCorrect answer
Community Expert
Oct 23, 2023 5:57 PM UTC

The "deletePages" function is a member of the document object.

So it's this.deletePages(...)

 

Always check the Acrobat JavaScript Reference.

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often

16 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
Oct 23, 2023 5:57 PM UTC

The "deletePages" function is a member of the document object.

So it's this.deletePages(...)

 

Always check the Acrobat JavaScript Reference.

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Papo C.Author
Participating Frequently
Oct 24, 2023 2:29 PM UTC

Hello, thank you for the advice but it still didn't work.

Translate
Bernd Alheit
Community Expert
Community Expert
Oct 19, 2023 8:16 PM UTC

Use deletePages

Translate
Papo C.Author
Participating Frequently
Oct 20, 2023 3:40 PM UTC

Hello!  Thank you for the advice but it still doesn't work.  Any other recommendations?

Translate
Bernd Alheit
Community Expert
Community Expert
Oct 21, 2023 4:09 AM UTC

Check the JavaScript console for errors.

Translate