Expand my Community achievements bar.

SOLVED

Populate Listbox Dynamically from Multiple Instance Text Fields

Avatar

Level 2

COLLAPSED:

Collasped.png

EXPANDED:

Screenshot.png

Currently in the "Borrower Names" List Box I have my code as (in the ENTER event):

this.clearItems();  

this.rawValue = null;  

 

var nCount = Section2.Table1.instanceManager.count;  

var nCount2 = Section2.Table1.instanceManager.count; 

for (var i=0; i<=nCount; i++) 

     var vFld = xfa.resolveNode("Section2.Table1[" + i + "]"); 

     var vObj = vFld.Guarantor.Row1.GaurantorFirstName.rawValue;  

     this.addItem(vObj);  

}

for (var i=0; i<=nCount2; i++) 

     var vFld2 = xfa.resolveNode("Section2.Table1[" + i + "]"); 

     var vObj2 = vFld2.NonGuarantor.Row1.NonGaurantorFirstName.rawValue;  

     this.addItem(vObj2);  

}

When a new instance is added, the user can either choose Guarantor or Non Guarantor. Both sections have a "First Name" text field. These names need to be added to the listbox under "Borrower Names" under Section 3. Need help correcting the code to make it work. Please let me know if you have any questions! Thanks!! I am only getting "Bob" to show up instead of both "Bob" and "Jane" (referring to example above)

FORM LINK Dropbox - Loan Submission Form.pdf

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi there,

First, you shouldn't be doing 2 loops for the same table.

Second, the fact that you do not verify guarantor and not guarantor may cause errors because if one of them is hidden and filled, it will still add the names to the list box.

Third, when adding a value into a list box always ensure to verify if the value is different than null, this way if a name is missing it will not cause an error and still add all the items as requested.

here how it should look :

Hope this will help you for other times.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi there,

First, you shouldn't be doing 2 loops for the same table.

Second, the fact that you do not verify guarantor and not guarantor may cause errors because if one of them is hidden and filled, it will still add the names to the list box.

Third, when adding a value into a list box always ensure to verify if the value is different than null, this way if a name is missing it will not cause an error and still add all the items as requested.

here how it should look :

Hope this will help you for other times.

Avatar

Level 2

THANK YOU!!! I appreciate your help! That worked