Skip to main content
Participating Frequently
October 19, 2023
Answered

Java Script Delete Page

  • October 19, 2023
  • 2 replies
  • 2386 views

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 has been closed for replies.
Correct answer Thom Parker

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

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

 

Always check the Acrobat JavaScript Reference.

 

 

2 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
October 23, 2023

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
Papo C.Author
Participating Frequently
October 24, 2023

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

Bernd Alheit
Community Expert
Community Expert
October 19, 2023

Use deletePages

Papo C.Author
Participating Frequently
October 20, 2023

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

Bernd Alheit
Community Expert
Community Expert
October 21, 2023

Check the JavaScript console for errors.