These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Delete Pages using JavaScript

WalterAPO
Registered: Jun 1 2009
Posts: 9

I made a time and attendance form with includes a overtime form which is two pages. If the employee didn't have overtime I made a button to delete the overtime pages. I can't get the button to work. Below is my JavaScript. I been reading and reading, but I can't figure out what I did wrong. I very new to java scripting. I'm using Livecylce Designer ES 8.2. I have to adjust for the zero based page numbering, but does the Master page start at 0 or the Title page 0. I tried both, but neither worked. Any ideas?

form1.TitlePage.Button2::click - (JavaScript, client)
this.deletePages({nStart:4, nEnd:5});

My Product Information:
LiveCycle Designer, Windows
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
This will delete the last two pages of any document (provided it has more than two pages, of course):
this.deletePages({nStart: this.numPages-2, nEnd: this.numPages-1});

Edit: Oops... there was an error in my code. It's fixed now.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

WalterAPO
Registered: Jun 1 2009
Posts: 9
I tried this several times and I can't get the pages to delete. I cut and pasted the code into the script console for the button. I have in under "Click" to activate the Javascript. When I open the form in Acrobat Pro 9 and mouse click the button nothing happen. The print and rest button work. I don't know what is wrong. I have been reading a lot of articles on this web site and Adobe to fix the button. Any ideas on what I am not doing or doing wrong? Thank you, Walter.
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
Be more specific. What happens exactly? Do you get any error message?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

WalterAPO
Registered: Jun 1 2009
Posts: 9
I been trying to fix my Javascript with no success. I watch an outstanding video on Abobe from Thom about Javascripting. I learned a lot, but I still have a problem. I turned on the JavaScript console and I received the following error. "Unable to find source for XFA:form1[0]:P1[0]:Button2[0]:Click". Any suggestions on how to fix this problem. Again, thank you.

Walter
WalterAPO
Registered: Jun 1 2009
Posts: 9
Hello, I using Livecycle 8.2ES to make my form and I have been reading. In Converting Acrobat® JavaScript for Use in LiveCycle™ Designer Forms it stated the this.deletePages was not supported by Livecycle. Then I search the Livecycle web page at http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Adobe_LiveCycle_Designer_Help&file=001196.php and it stated that deletePages was not supported by Livecycle. "In LiveCycle Designer ES, you can use the instanceManager object to remove the subform object that represents a page of your form.
For more information, see To add and remove subform instances using scripting." I went ot the web site and it state that the JS to remove instances is "Subform1.instanceManager.removeInstance(integer)." What do I use for the (integr)? I very very new to JS so I don't know how to proceed. Thank you.


Walter