469,643 Members | 1,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

How to get the size of a SELECT element?

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

Mar 12 '07 #1
3 12125
la***********@zipmail.com wrote on 12 mrt 2007 in comp.lang.javascript:
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.leng th
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 12 '07 #2
Evertjan. wrote:
la***********@zipmail.com wrote on 12 mrt 2007 in
comp.lang.javascript:
>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.leng th
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 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
I would prefer just to look at document.getElementById('mySelectId').type

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Mar 13 '07 #3
"Matt Kruse" <ne********@mattkruse.comwrote in
news:et********@news3.newsguy.com:
I think he meant the number of _visible_ items. Meaning, how many fit
within the dropdown window area.
var s = document.getElementById('mySelectId').size
Mar 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Rithish | last post: by
1 post views Thread by laredotornado | last post: by
1 post views Thread by CMani | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.