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

removeInstance problem

hattg
Registered: Jun 18 2009
Posts: 36

I have been able to get my addInstance and removeInstance scripts to work, but I am having a small issue with the removeInstance.

I have a delete button at the beginning of each row in my table which works, sort of. What happens is if you click the delete button on any row other than the first, it always deletes the first row and moves the other rows up. I need it to delete the actual row I am clicking on, and not always just delete the first row.

Is this possible?

The add button code is:
form1.BaseSubform.Occupants.OccupantSection.Occupant1.instanceManager.addInstance();

The delete button code is:
var nNodes = OccupantSection.resolveNodes("Occupant1[*]").length;
if(nNodes > 1)
Occupant1.instanceManager.removeInstance(this.parent.index);

Thanks

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
First, what you really want as the qualifier is this:
if(_Occupant1.count> 1){}

Are you sure of the hierarchy?? Is the delete button maybe two levels into the repeated subform? Add this line of code to the delete button.
console.println("Parent instance: " + this.parent.name + " = " + this.parent.index);
Then open the form in Acrobat, not the LC preview window. Open the JavaScript console window and see what's printed there when you hit the delete button.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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