Script to finds and delete blank items in ListBox list



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).

Accepted Solutions (1)

Accepted Solutions (1)



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.