Populate Listbox Dynamically from Multiple Instance Text Fields

Avatar

Avatar

BGreggs4

Avatar

BGreggs4

BGreggs4

01-08-2017

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Magus069

MVP

Total Posts

1.0K

Likes

132

Correct Answer

150

Avatar

Magus069

MVP

Total Posts

1.0K

Likes

132

Correct Answer

150
Magus069
MVP

01-08-2017

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.

Answers (1)

Answers (1)

Avatar

Avatar

BGreggs4

Avatar

BGreggs4

BGreggs4

02-08-2017

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