Javascript Reference
Categories: SELECT

javascript SELECT options[ ]

@March 15, 2008, 1:22 a.m.
options[ ]Firefox/Netscape/NN 2 IE 3 Chrome/Safari/DOM 1  

Read-only  

Returns an array of all option objects contained by the current element. Items in this array are indexed (zero-based) in source code order. For details on using this collection in a backward-compatible way for adding and removing option elements from a select element, see the options object. Loop through this collection in select elements set for multiple selections.

 
Example
 
var selVals = new Array( );
for (var i = 0; i < document.forms[0].mySelect.length; i++) {
    if (document.forms[0].mySelect.options[i].selected) {
        selVals[selVals.length] = document.forms[0].mySelect.options[i].value;
    }
}
 
Value

Array of option objects.

 
Default

None.


Powered by Linode.