Javascript examples for DOM HTML Element:Select
The Select object represents an HTML <select> element.
You can access a <select> element by using getElementById():
<!DOCTYPE html> <html> <body> <select id="mySelect" size="4"> <option>CSS</option> <option>HTML</option> <option>Java</option> <option>Javascript</option> </select>//from www . j a v a 2s .c o m <button onclick="myFunction()">get the number of option elements found in a drop-down list</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("mySelect").length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>