JavaScript Reference/Javascript Collections/options — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:22, 26 мая 2010

"options" Example

    
<html>
<body>
<select id="mySelect">
    <option>List Item 1</option>
    <option>List Item 2</option>
    <option>List Item 3</option>
</select>
<button onclick="alert(mySelect.options.length);">Number of options in the select list</button>
</body>
</html>



"options" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<select>                                                      |
+----------------+--------------------------------------------------------------+



"options" JavaScript properties and JavaScript methods

JavaScript properties and JavaScript methods
 
add(), item(), length, namedItem(), remove(), tags(), urns()



"options" Syntax Parameters and Note

Note:
Returns an array of all the <option> elements in a <select>.
    
Syntax:
    
document.getElementById("selectID").options // returns all options
document.getElementById("selectID").options(param1, param2) // returns an individual option
document.all.selectID.options // IE only
document.all.selectID.options(param1, param2) // IE only
Parameters:
    param1   Required; zero-based index or
                       desired member"s id or name attribute.
                       
    param2   Optional; the zero-based index for the result returned
                       if param1 matches more than one element.