An HTML selection list consists of two elements: <select> lays the foundation and provides the name of the whole list (in its name attribute). The actual list elements are represented by <option> elements and provide two things: a caption (the data shown in the browser) and the value (the data sent to the server when the form is submitted). When you're working with JavaScript, two ways of accessing the list data are available:
Usually, selectedIndex is good enough for validation purposes. The options approach comes in quite handy when the selected list element will be accessed, as well. Then, the value attribute of the selected option provides the data sent to the server, and the text property returns the caption visible in the browser. The following listing accesses all important information regarding the selected option: Accessing a Selection List (selectionlist.html)
Note Recent browsers also support the following shortcut for accessing the value of the currently selected list element: f.elements["selectionlist"].value However, to maintain maximum browser compatibility, the following approach requires a bit more typing, but also works on older software: f.elements["selectionlist"].options[ f.elements["selectionlist"].selectedIndex].value |