Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Script to finds and delete blank items in ListBox list

DKinsley
Level 9
Level 9

My form has some items added to a ListBox by the form user.

I need a script that will loop through the ListBox list, find and delete any items that display as blank (can click in that row but no text is displayed).

1 Accepted Solution
jasotastic81
Correct answer by
Level 7
Level 7

You may need to modify this a little to suit your purposes: It doesn't catch list items with a blank space.


var lbList = xfa.resolveNode("lbStuff.#items");


for (i = lbStuff.length-1; i>=0; i--){


if (lbList.nodes.item(i).value == "") lbStuff.deleteItem(i);


}



I tested with a list box "lbStuff" that contained "15", "", " ", and "16" as values. This script removed the "", but left the " ". So if it is possible for the user to add an item with spaces and no text, it will need to be modified a little.

View solution in original post

2 Replies
jasotastic81
Correct answer by
Level 7
Level 7

You may need to modify this a little to suit your purposes: It doesn't catch list items with a blank space.


var lbList = xfa.resolveNode("lbStuff.#items");


for (i = lbStuff.length-1; i>=0; i--){


if (lbList.nodes.item(i).value == "") lbStuff.deleteItem(i);


}



I tested with a list box "lbStuff" that contained "15", "", " ", and "16" as values. This script removed the "", but left the " ". So if it is possible for the user to add an item with spaces and no text, it will need to be modified a little.

View solution in original post

DKinsley
Level 9
Level 9

As far as I can tell, your script solved my problem.

Thank you so very much for your help!