Select.options : Select « Form « JavaScript Tutorial






The options property is an array that contains the option elements in the select box.

This property is used to retrieve properties of the options in a select box, such as the value or text.

<html>
    <head>
    <script language="JavaScript">
    <!--
    function infoBox(form){
      var myIn = form.mySelect;

      var myWin = open("", "","width=400,height=150");
  
      for (var i = 0; i < form.mySelect.options.length; i++) {
        if (form.mySelect.options[i].selected){
          myWin.document.write('<br><b>Value:</b> ' + myIn.options[i].value);
          myWin.document.write('<br><b>Text:</b> ' + myIn.options[i].text);
          myWin.document.close();
        }
      }
    }
    -->
    </script>
    </head>
    <body>
    <form name="myForm">
      <select name="mySelect" onChange='infoBox(this.form)'>
        <option value=A>AA</option>
        <option value=B>BB</option>
        <option value=C>CC</option>
        <option value=D>DD</option>
      </select>
    </form>
    </body>
    </html>








10.12.Select
10.12.1.Select
10.12.2.Select.blur()
10.12.3.Select.focus()
10.12.4.Select.form
10.12.5.Select.handleEvent()
10.12.6.Select.length
10.12.7.Select.name
10.12.8.Select.onBlur
10.12.9.Select.onChange
10.12.10.Select.onFocus
10.12.11.Select.options
10.12.12.Select.options.length
10.12.13.Select.options.selectedIndex
10.12.14.Select.options.value
10.12.15.Select.selectedIndex
10.12.16.Select.type
10.12.17.Triggering a Value Change from a Pop-Up Menu
10.12.18.Grouped selection control on change event