Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Delete button script to delete two consecutive pages in the middle of a document.

New Here ,
Mar 31, 2023 Mar 31, 2023

Hi. I've been roped into creating a credit card application and have zero javascript experience. I've been doing the best I can but have ran into something I cannot seem to work around.

 

When selecting the appropriate legal structure (using radial boxes with four options), we need to spawn a two page resolution. The spawning works just fine. However, if a person selects "Corporation" and then selects "Partnership," both resolutions are spawned. If I could code, I would have written the script to delete the spawned pages when selecting a different radial button (I did try and got it to work by hiding/unhiding the templates...doesn't work on all versions).  So....I added a delete page button on each resolution but can't figure out how to make it work if the two pages to delete happen to be in the middle of the document. This works fine if no other pages are spawned throughout the document but, as you can see, this deletes all but 4 of the pages (that's the starting point of the application). Any advice on either fixing the code for the delete button or fixing the code for the spawn would be greatly appreciated. 

 

For the Delete button I'm using the following:

if (numPages > 5) {
this.deletePages(4, this.numPages-1);
}

 

For spawning the resolutions, I'm using the following:

var a=this.getTemplate("LLC Auth")
var b=this.getTemplate("LLC Auth2")

if(event.target.value == "Off")
this.deletePages(event.target.page+1);
else
a.spawn(numPages,false,false);
b.spawn(numPages,false,false);
this.pageNum=event.target.page+1;
this.pageNum=-1;

TOPICS
How to , JavaScript , PDF forms
874
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2023 Mar 31, 2023

If you don't want to have more than two spawned pages at a time then in the same 'radio' button where you spawn pages, first add script to delete pages if the number of pages is bigger than 4 and then script to spawn pages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 03, 2023 Apr 03, 2023
LATEST

That's what I currently have setup. Unfortunately, there are times when the user can spawn additional pages (for a different reason) resulting in more than 4 pages, ultimately deleting any work they may have completed prior to. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines