Question

I'm using LiveCycle Designer to build a dynamic form that is able to add and delete rows of a nested table and calculate the total of each row. The calculation uses FormCalc and utilizes the [*] function to address all iterations of a row. (eg. ...someThing.Row1[*] instead of ...someThing.Row[0], ...someThing.Row[1], etc.)

This works perfectly, but I'd also like to use Javascript to alter the background fills of certain text field cells on a button mouseUp. I can get it to work targeting specific cells, but I'm not sure what steps to take in Javascript to address all dynamic iterations of an element.

For example, this JavaScript works but only targets single cells:

MainForm.roomTableSubform.roomTable.Row1.Table1.Row1.billWidth.fillColor = "0,0,0";

Logically, (as I understand) if using FormCalc, to target the duplicated rows, the code would simply be something to the effect of:

MainForm.roomTableSubform.roomTable.Row1[*].Table1.Row1[*].billWidth.fillColor = "0,0,0";

This obviously does not work with Javascript. I've read what I can find about resolveNode and it seems this is the JavaScript solution. I am just unsure of how to use it in context to target an undisclosed number of dynamically created elements.

I've enclosed the entire expression within resolveNode, started the expression with xfa.resolveNode("..., used the asterisk within resolveNode (resolveNode("Row1[*]")), stuck it right where the Row is (Table1.resolveNode("Row1[*]").blah) and every other arbitrary combination I could think of, to no avail.

Any insight as to where I'm going wrong would be greatly appreciated. Thanks in advance.

Était-ce utile?

La solution

xfa.resolveNode() returns one node. You need to use xfa.resolveNodes() to return a collection of nodes using a SOM expression. And you can traverse the nodes with a loop.

var nodes = Table1.resolveNodes("Row1[*]");
var len = nodes.length;
for(var i = 0; i < len; i++){
    nodes.item(i).fillColor = "255,200,200";
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top