Select.options : Select : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » Select »

 

Select.options








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>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» Select