Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Script to finds and delete blank items in ListBox list

Avatar

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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.

Avatar

Level 9

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

Thank you so very much for your help!