How do you referance a textbox in an instance of a Subform Set


I have a form with the following hierarchy.


On page1 I have a dynamic table with an add button, textbox, and delete button. I have the form javascript set so it will create an instance of the sfsDefendants which consists of pages3 - 5.

When the users enters a name in the textbox on the table I have the script run on the exit event.

Basically it collects whatever was entered into the instance of the textbox on page1 and populates this info out to the other txtDefendants textboxes on the other pages.

I can get it to populate the first time through for the page5 txtDefendants boxes, but not on the second or more instances. From troubleshooting it looks like it has something to do with the hierarchy since I have other subforms in page5.

Any help is greatly appreciated.


Software Manager

4 Answers

For a script that is outside the repeated subform, the field is accessed through the instance number of the repeated subform. To do this you need to learn about the "resolveNode()" function.

Inside the repeated subform its not a problem because the fields can be referenced using relative paths.

I used to have a really great video on this site that explained exactly what it is you need to, but it was lost in the transition to the new format :( However, I do have many more videos that explain everything you need to know in much greater detail, with downloadable examples, at

Thom Parker
The source for PDF Scripting Info

The Acrobat JavaScript Reference, Use it Early and Often

The most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Having trouble, Why Doesn't my Script Work

Thom Parker   


I was not able to post my script in my origional post, but here it is.

var a = xfa.resolveNode("form1.page1.tblDefendant.Table1.Row1[" + this.parent.index + "]").txtDefendant.rawValue;

xfa.resolveNode("form1.sfsDefendants.page3[" + this.parent.index + "]").txtDefendant.rawValue = a;

xfa.resolveNode("form1.sfsDefendants.page4[" + this.parent.index + "]").txtDefendant.rawValue = a;

xfa.resolveNode("form1.sfsDefendants.page5.affidavit_header[" + this.parent.index + "]").txtDefendant.rawValue = a;

xfa.resolveNode("form1.sfsDefendants.page5.affidavit_trailer[" + this.parent.index + "]").txtDefendant.rawValue = a;

As you mentioned I should use the resolveNode command, which I am. When I enter data in the textbox on page1, it populates out to all of the page3 and page4 instances, but only to the first instance of page5. I will also review the website you posted for a reference.



Software Manager   

So "affidavit_header" is the repeated subform? And there are exactly the same number of this subform as there are of the "sfsDefendants" subforms? You're also missing the DOM part of the path, i.e., "xfa.form.form1". Where "form" indicates the form model.

Your best bet for figuring this out is to debug your last line of code, the code for page 5, in the JavaScript Console. To do this you'll need to run the form the Acrobat, not the preview window in Designer.


Instead of using "this.parent.index", use hard coded numeric values. And don't include the assignment value. Find out where it breaks down. Start out by running smaller segments, making sure each one returns an [object xfaObject] value in the console window. For example:


Just as a point of programming style, the path for executing resolveNode can start at the first ancestor (parent) node that is in common with the target and source nodes.

Thom Parker   


I played around some more with the code andfound that the following code worked.

xfa.resolveNode("form1.sfsDefendants.page3["+this.parent.index + "]").txtDefendant.rawValue = a;

xfa.resolveNode("form1.sfsDefendants.page4["+this.parent.index + "]").txtDefendant.rawValue = a;

xfa.resolveNode("form1.sfsDefendants.page5["+this.parent.index + "]").affidavit_header.txtDefendant.rawValue = a;

xfa.resolveNode("form1.sfsDefendants.page5["+ this.parent.index + "]").affidavit_trailer.txtDefendant.rawValue = a;

Software Manager   

Please specify a reason: