ResolveNode/Find node? | Community
Skip to main content
New Participant
August 1, 2006

ResolveNode/Find node?

  • August 1, 2006
  • 17 replies
  • 5767 views
Hello!



I was wondering if there is a function to find a field by name in a PDF.

I already saw a lot of examples using Resolvenode, however, these examples always used the path to the node (page.subform.etc). Because I don´t know where the field will be or even if the fields really exists, I would like to search for it easily. The only solution I had found was to interact through all the nodes on each page, but this seems not very efficient.



Thank you
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

17 replies

neptasAuthor
New Participant
August 2, 2006
Hi,



Sorry, I just work inside an Intranet...

The form where I tested is very simple: two subforms with a text field in the second one. Then I use this code at doc ready event of the main form:



var c = xfa.resolveNode("TextField1");

app.alert(c); //Gets null ....



Thank you!
August 2, 2006
Shouldn't be a version problem. It seems to work here for me. Can you put your form online somewhere that I can take a quick look at it?



Chris

Adobe Enterprise Developer Support
neptasAuthor
New Participant
August 2, 2006
Chris,



Despite it seems simple, I can´t see xfa.resolveNode("MyTestField"); working... I always get a null object/value. I´m using Acrobat Professional 7.0.5. Can it be a version problem?



Thank you
August 1, 2006
I got the first two JavaScript examples to work. Thanks.



I held down the control key then clicked on the field I wanted to access to get the following path.



xfa.resolveNode("form1.mainPage.mySubForm.Field2")



Then I made some changes to some of this line as in,



xfa.resolveNode("form1.mainPage.mySubForm[1].Field2");



I couldn't understand why it wasn't working when I put in the instance number (mySubForm[1]). It seemed logical to me. It looks like I have to isolate the instance inside the parenthesis first then access the field outside the parenthesis.
August 1, 2006
So there are a few ways you can do this:



In JavaScript:



form.somToParentSubForm.resolveNode("mySubForm[1]").Field2.rawValue = "test";



or



var nodeList = form.somToParentSubForm.resolveNodes("mySubForm[*]");

nodeList.item(1).Field2.rawValue = "test";



In FormCalc you could go direct:



form.somToParentSubForm.mySubForm[1].Field2.rawValue = "test";



Basically, '[' and ']' can't be used in a JavaScript expression so you use resolveNode in JavaScript to access the specific instance of the subform you want.



Chris

Adobe Enterprise Developer Support
August 1, 2006
I have a question to go along with this. I'm still not clear on how to get to a certain field in one of the instances of a subform. For example



There are four instances of a subform called mySubForm. In each of the subforms there are three fields: Field1, Field2, Field3. How do I get or set the value for "Field2" in the second instance of the subform?



The occurances of the subform is defined in the Repeat Subform for each Data Item > Initial Count = 4.
August 1, 2006
Say for example the field is called MyTestField, you can use resolveNode() to search for it like so:



xfa.resolveNode("MyTestField");



This is much less efficient than drilling down a bit and looking in a specific section, but if you have no idea where the node could be then you don't have much choice. This will start from the top and search the DOM node by node until it finds MyTestField.



Chris

Adobe Enterprise Developer Support