Select : Select « Form « JavaScript Tutorial






Instances are created by the browser when it encounters an HTML

Event Handlers/Methods/PropertiesDescription
onBlurExecuted when the select box loses the focus.
onChangeExecuted when the select box loses the focus and has had its value modified.
onFocusExecuted when the select box receives the focus.
blur()Removes the focus from the select box.
focus()Gives the focus to the select box.
handleEvent()Invokes the handler for the event specified and was added in JavaScript 1.2.
formReturns the entire form the select box is in.
lengthReturns the number of options in the select box.
nameReturns the name of this select box specified by the NAME attribute.
optionsReturns an array containing each of the items in the select box. These items are created using the
selectedIndexReturns an integer specifying the indexed location of the selected option in the select box.
typeReturns the type specified by the TYPE attribute. For


<html>
    <head>
    <script language="JavaScript">
    <!--
    function openWin(){
      var myInstance = document.myForm.mySelect;
      var myWin = open("", "","width=450,height=200");

      myWin.document.write("The length is: " + myInstance.length + "<br>");
      myWin.document.write("The name is: " + myInstance.name + "<br>");
      myWin.document.write("The selected option is located at position: ");
      myWin.document.write(myInstance.selectedIndex + "<br>");
      myWin.document.write("The type is: " + myInstance.type + "<br>");

      myWin.document.write(myInstance.form.myButton.value);
      myWin.document.close();
    }
    -->
    </script>
    </head>
    <body>
    <form name="myForm">My Favorite Sport is:
      <select name="mySelect">
        <option value=A>AA</option>
        <option value=B>BB</option>
        <option value=C>CC</option>
        <option value=D>DD</option>
      </select>
    <input type=BUTTON value="Click to Process" name="myButton"
             onClick="openWin()">
    </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