Skip to main content
Inspiring
February 13, 2024
Answered

Javascript to delete pdf pages using a form field as page marker

  • February 13, 2024
  • 1 reply
  • 2257 views

Hi there,

 

I would like to know if anyone has found javascript that would find a specific form text field name and then delete the page it is on?

 

I am working on a form that new pages will be added if the client uses a dropdown to select number of accounts and the template spawns from that. But I would like to give the client the opportunity to change the number of spawn pages if they have got it wrong. Complete novice to this. I did the original with show hide javascript but the client has asked for the pages to delete. 

This topic has been closed for replies.
Correct answer Nesa Nurani

You can use 'page' property to find page number of a specific field, for example let's say you want to delete page where "Text1" field is located:
var f = this.getField("Text1").page;
this.deletePages(f);

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
February 13, 2024

You can use 'page' property to find page number of a specific field, for example let's say you want to delete page where "Text1" field is located:
var f = this.getField("Text1").page;
this.deletePages(f);

Inspiring
February 14, 2024

Hi Nesa,

 

Thanks for your help. I have added the code to a Combo Box in the calculate script custom calculation area.

 

var v = this.getField("Combo Box 1").value; if (v === “two”) { var f = this.getField("Text 2").page; this.deletePages(f); } if (v=== "three"){ var g = this.getField("Text 3").page; this.deletePages(g); }

But it doesn't seem to be working.

Have I done something wrong

try67
Community Expert
Community Expert
February 14, 2024

There are errors in your code. Check the JS Console. You must always use straight quotes, not curly ones.