Skip to main content
Known Participant
May 3, 2018
Question

delete pages after the choice change with a dropdown list

  • May 3, 2018
  • 1 reply
  • 1094 views

Hi ! i am working with acrobat DC (15) on Windows.

thanks to : Spawn a page using drop down box (JavaScript) , i am able to spawn a template.

I have a dropdown list with 3 choices (A,B and C) and a button submit ( the code from the topic are inside this button) and then i spwan a template.

However, i would like to delete the template if the user change his choice from A to B ...

i konw how to delete a page : {this.deletePages(1)} but where i could apply it ???

Thxxxxxxx !!!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 3, 2018

In the same place where you're spawning the pages. You will need to first check if there's a need to delete such a page, though.

For example, you can check the total number of pages in the file (numPages property). If it's not the original number, delete the additional pages and then spawn the new ones.

Known Participant
May 3, 2018

I am really a newbie ... may i have some code ?? =)

I have this :

// get the value from the dropdown control

var sel = this.getField("liste_qualif").value;

// determine the template name

var templateName = "";

switch (sel) {

  case 1: templateName = "CRI";

    break;

  case 2: templateName = "FI";

    break;

  case 3: templateName = "FTI de FTI";

    break;

    case 4: templateName = "FTI";

    break;

    case 5: templateName = "IRI";

    break;

    case 6: templateName = "MCCI";

    break;

    case 7: templateName = "SFI";

    break;

    case 8: templateName = "STI";

    break;

    case 9: templateName = "TRI";

    break;

}

// if we have a template name, spawn the template

if (templateName != "") {

  var t = this.getTemplate(templateName);

  t.spawn();

}

try67
Community Expert
Community Expert
May 3, 2018

How many pages are there in the file before you spawn the template?

Are you always spawning the new pages as the last pages of the file?