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

delete an instance of subform at runtime

neuron
Registered: Mar 13 2007
Posts: 4

I have added some new instances of a subform using addInstance method on click of a button.
I want to delete any instance on click of a delete button at run time . The removeInstance( INTEGER param ) method needs an int parameter.

My Product Information:
Acrobat Pro 7.0.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If the script is being executed from inside the instance you want to delete, the instance number can be acquire directly from the current object.

For example, if the script is run from a click event on a button inside the repeated subform (i.e. a delete button)

The subform index is:

var subIndex = this.parent.index;

If you want to use a button that is outside the repeated subform you'll need a way to id the particular subform that you want to delete, like a check box in each of the repeated subforms.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

neuron
Registered: Mar 13 2007
Posts: 4
i have used this.parent.index;
now i have to find out which subform is being deleted,

var subIndex = this.parent.index;
when I am printing it in the console using
console.println("index: " + subIndex);
it gives '0' for every subform i delete.
ChrisFreeman
Registered: May 6 2007
Posts: 19
If your delete button is part of the "row", then you can use code similar to:

Table1.resolveNode("row[" + this.parent.index + "]").instanceManager.removeInstance(1)

Otherwise, like Thom said, there is no context to specify the instance you wish to remove.