473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 12328
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. Here's the code: window.onload = init; function...
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? There is plenty of void room below two OPTIONs in...
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 of a text box element. Also, if the list box...
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 following code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD...
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 if the element was of a MULTIPLE type or not? ...
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 in value and ATTRIB respectively for each code in...
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 <select> element in html with javascript. Among the...
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 it only fires after you hit the enter key, which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.