Select.size (Property)

The number of items currently chosen in the select popup.


DOM level - 1
JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Property/method value type:Number primitive
JavaScript syntax:-mySelect.size

This is an integer value which is likely to be 1 most of the time. It is only meaningful if the Select.multiple property is true and more than one item has been selected.

Here is a workaround for other browsers that don't have this property, kindly donated by Jon Stephens:

   var mySize=0;
   for(var i=0; i<mySelect.options.length; i++)
      mySize += mySelect.options[i].selected ? 1 : 0;
   mySelect.size = mySize;

See also:Select.multiple