Hi all,
I have designed a dynamic form with a dataconnection that points to an XML file.
The fields in my form are displaying the correct values from the XML file. That all goes well.
But now, I want to set the color of some textfields depending on the value of a certain element in the XML file.
How can I access an element from the dataconnection using javascript?
Any ideas on the syntax I shoul use?
regards,
Peter Vermeule
Belgium
Views
Replies
Total Likes
You can access the dataDom by using the prefix to your xml structure xfa.datasets.data....your data structure goes here..If you are unsure of the structure I like to add a large multiline field (for debugging urposes only) and on the docReady event I use the command this.rawValue = xfa.datasets.data.saveXML("pretty"). This will dump the datadom onto that field and I can see the structure that I need to follow. To retrieve the actual value from the dom ....you path to the node you want and use the value property to retrieve the value of that node.
Hope that helps
Paul
Hi,
Also you can get some values from mapped xml with this script:
xfa.resolveNode("$record.messages.btn_some_text").value
BR
Views
Replies
Total Likes
Thank you for your help.
Using the xfa.datasets.data.saveXML("pretty") function shows the complete xml, but I'm not able to get the value of a single element inside the xml.
My xml is as follows:
<QEDREP jobname="[271] W817312010111-08.zip" customer="PEVE">
<generated>2009-06-25 09:29:59</generated>
</QEDREP>
I want to have the value of the generated element. When I use this javascript function to show the value, the messagebox is empty...
xfa.host.messageBox(xfa.datasets.data.QEDREP.generated.value, "XML value of 'generated' element", 3);
Can you help me once more, please?
regards,
Peter
Views
Replies
Total Likes
Hi,
try this one
xfa.host.messageBox(xfa.resolveNode("$record.QEDREP.generated").value, "XML value of 'generated' element",3)
BR
xfa.host.messageBox(xfa.resolveNode("$record.generated").value, "XML value of 'generated' element",3)
did the job. The name of the root element (QEDREP) was not necessary.
thanks for your help,
Peter
Views
Replies
Total Likes
Hi,
a (hopefully) last question:
I have a table on my dynamic form. The binding of a textfield inside my table is as follows:
$.element1.element2[*].element3
The result of this is that for each element2 under element1, the value of element3 is shown in the table as a separate row.
So far, so good.
But now, inside the javascript attached to the textfield, I want to know the value of an attribute on element3 that is shown in the current textfield. Is this possible?
I tried a syntax like this:
fa.resolveNode("$record.element1.element2[*].element3.name_of_my_attribute").value
Without success!
thanks again for your help,
Peter
Views
Replies
Total Likes
Hi,
if you are teking data with this element2[*] it means that you are takin list for thi you shoul use xfa.resolveNodes instead xfa.resolveNode, also you cant take value of list, only item(index).value.
And check this article http://blogs.adobe.com/formfeed/2008/10/data_binding_with_predicates.html
BR
Views
Replies
Total Likes
Is there a way to determine the rowindex of the textfield inside the table (using javascript), so I can take the correct item from the returned nodelist?
Peter
Views
Replies
Total Likes
While in an event of the textfield you wish to know the index of use 'this.parent.index'
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies