Select : Select : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » Select »

 

Select










Instances are created by the browser when it encounters an HTML

In the JavaScript object hierarchy, the Select object is located at window.document.Form.Select.

Event Handlers, Methods, and Properties Used by the Select Object























































Event Handlers/Methods/Properties Description
onBlur Executed when the select box loses the focus.
onChange Executed when the select box loses the focus and has had its value modified.
onFocus Executed 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.
form Returns the entire form the select box is in.
length Returns the number of options in the select box.
name Returns the name of this select box specified by the NAME attribute.
options Returns an array containing each of the items in the select box. These items are created using the
selectedIndex Returns an integer specifying the indexed location of the selected option in the select box.
type Returns 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>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» Select