How to get the size of a SELECT element?

L

laredotornado

Hi,

What is a cross-browser way to get the size (number of visible items)
of a SELECT element? If that is not possible, how would I determine
if the element was of a MULTIPLE type or not?

Thanks, - Dave
 
E

Evertjan.

What is a cross-browser way to get the size (number of visible items)
of a SELECT element?

If you mean the number of select options:

var n = document.getElementById('mySelectId').options.length
If that is not possible, how would I determine
if the element was of a MULTIPLE type or not?

If the select is multiple?

var m = document.getElementById('mySelectId').multiple


IE7 and FF2 tested.
 
M

Matt Kruse

Evertjan. said:
(e-mail address removed) wrote on 12 mrt 2007 in
comp.lang.javascript:
If you mean the number of select options:
var n = document.getElementById('mySelectId').options.length

I think he meant the number of _visible_ items. Meaning, how many fit within
the dropdown window area.
The answer, of course, is that there is no way to find this.
If the select is multiple?
var m = document.getElementById('mySelectId').multiple

I would prefer just to look at document.getElementById('mySelectId').type
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top