Add getFieldCount function to count the number of items in a dropdown or listbox