Skip to main content
Participating Frequently
October 19, 2023
解決済み

Java Script Delete Page

  • October 19, 2023
  • 返信数 2.
  • 2441 ビュー

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

このトピックへの返信は締め切られました。
解決に役立った回答 Thom Parker

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

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

 

Always check the Acrobat JavaScript Reference.

 

 

返信数 2

Thom Parker
Community Expert
Thom ParkerCommunity Expert解決!
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.作成者
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.作成者
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.