Expand my Community achievements bar.

SOLVED

Javascript Wildcard for Repeating Row

Avatar

Former Community Member

Hi there!

I  have created a dynamic form using LiveCycle Designer ES3.  In one subform I have set up a table with a Text Field.  This field is nested within the table in a row titled "Reasons" and this row is allowed to repeat (Figure 1) if the user clicks the "Add Another Reason" button (Figure 2). 

Figure 1

Figure 1.JPG

Figure 2

Figure 2.JPG

Notice in Figure 2 that the "Reason" text field has a red border indicating that the field is required.

Elsewhere in my form, there is a check box.  If the user checks this check box, then the "Reason" field in Figure 2 becomes disabled, nullified, and no longer mandatory.  However,  when the user clicks "Add Another Reason" and there is more than one instance of the "Reason" text field (indicated below in Figure 3), then checking the aforementioned check box does not work.  Therefore, what I need is some javascript "wildcard" to account for this repeating row, and subject this row to the same actions (disabling, nullifying, removing mandatory requirement) that the first row has.

Figure 3 (the check box mentioned above has been checked, but the 2nd instance of "Reason" below does not respond to the javascript that works fine on the first instance of "Reason")

Figure 3.JPG

I know with FormCalc you can use [*] as a wildcard to account for unknown instances of an object, and I have used this function successfully elsewhere in this form, however I do not know how to do this same type of function with JavaScript.  Please help.

Thank you!

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can use the wildcard if you use resolveNodes() instead of resolveNode() and it's more efficient (on large forms it can make a difference).

var r = xfa.resolveNodes("Table1.Row[*]");

//variables more efficient if declared outside the loop

if (cbNotNeeded.rawValue == 1) {

     for (var i = 0; i < r.length; i++) {

          r.item(i).border = "0.069in";

          //and whatever else you need to set

     }

}

I think the syntax is correct there just going off the top of my head.

More info here: http://blogs.adobe.com/formfeed/2011/06/resolvenode-vs-resolvenodes.html

View solution in original post

3 Replies

Avatar

Level 7

I've never seen a working wildcard in JavaScript. You'll need a for loop to cycle through, I think. If I'm wrong, I'm sure someone will correct me. In the meantime, try this.

if (cbNotNeeded.rawValue == 1){

     for (var i = 0; i<Table1.Row.instanceManager.count; i++){

          var r = "Table1.Row["+i+"]";

          xfa.resolveNode(r).border = "0.069in";

          //and whatever else you need to set

     }

}

Avatar

Correct answer by
Level 10

You can use the wildcard if you use resolveNodes() instead of resolveNode() and it's more efficient (on large forms it can make a difference).

var r = xfa.resolveNodes("Table1.Row[*]");

//variables more efficient if declared outside the loop

if (cbNotNeeded.rawValue == 1) {

     for (var i = 0; i < r.length; i++) {

          r.item(i).border = "0.069in";

          //and whatever else you need to set

     }

}

I think the syntax is correct there just going off the top of my head.

More info here: http://blogs.adobe.com/formfeed/2011/06/resolvenode-vs-resolvenodes.html