Click to See Complete Forum and Search --> : How to tell if a listbox is not empty?


K Lo
11-10-2003, 08:28 AM
Hi how do i tell a listbox field is not empty? ie it has values in it.

can i use document.forms[0].fieldA.selectedIndex=="" ?
or there are better ways of doing it?

Thanks in advance for any help!

olerag
11-10-2003, 08:44 AM
Yes, iterate thru the <select> options to see if any options are
selected. You can store the results in an array or simply
"break" from the loop.

K Lo
11-10-2003, 08:55 AM
hi can i use document.forms[0].fieldA.length to determine if there are values in it?

if there is only 1 value returned, will i get problems in determining it?

Thanks