472,353 Members | 1,242 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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 12244
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. ...
1
by: Marek Mänd | last post by:
<select multiple style="height:200px;"> <option>a <option>b </select> Why does Mozilla draw the vertical scrollbar to the SELECT html element?...
4
by: Rithish | last post by:
Is there a way to obtain the height of a <SELECT> element dynamically, i.e. through javascript? I want to dynamically display a list box onFocus...
13
by: Oliver Hauger | last post by:
Hello, In my html form I show a select-element and if this element is clicked I fill it per JavaScript/DOM with option-elements. I use the...
1
by: laredotornado | last post by:
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...
1
by: CMani | last post by:
Hi, I have an select element which has hidden attribute for each of item. Say Employee Id are listed in List Box, the Name and gender are kept...
5
tjc0ol
by: tjc0ol | last post by:
Hi all, I made contact page which allows visitors to input their name, email address, phone number, comments and select a comment type by using...
13
by: andypb123 | last post by:
Hello, The onchange event fires in IE6 in a SELECT element when scrolling through the list with the up and down arrows on the keyboard. In Firefox...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.