topical media & game development

talk show tell print

professional-javascript-11-ListboxSelectedIndexExample.htm / htm



  <html>
      <head>
          <title>Listbox Selected Index Example</title>
          <script type="text/javascript">
              function showSelectedIndex() {
                  var oListbox = document.getElementById("selListbox");
                  alert(oListbox.selectedIndex);
              }
          </script>
      </head>
      <body>
          <form>
              <select id="selListbox" size="5">
                   <option>Original Value 0</option>
                   <option>Original Value 1</option>
                   <option>Original Value 2</option>
                   <option>Original Value 3</option>
                   <option>Original Value 4</option>
              </select><br />
              Select an option in the listbox and click "Show Selected Index".<br />
              <input type="button" value="Show Selected Index" onclick="showSelectedIndex()" />
         </form>
      </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.