Name

length — NN 2 IE 3 DOM 1

Synopsis

Read/Write

The number of OPTION objects nested inside the SELECT object. You can adjust this value upward or downward, but there is some browser-specific behavior to watch out for. To genuinely add options to a SELECT object, you must follow the browser-specific way of creating new OPTION objects (see the options object for details). If you set this property to a number smaller than its original value, OPTION objects are deleted from the bottom of the list. A value of zero does not cause the element to disappear, but there are no selectable options in the element.

Example

document.forms[0].mySelect.length = 3

Value

Integer.

Default

None.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.