Drop Down List select box in javascript

Select index dropdown list in java script. Selected value in dropdown list and find all value from drop down list in javascript.




<HTML>
 <HEAD>
  <script>
    function findSelectedIndex(objList){
        alert(objList.selectedIndex)
    }

    function findSelectedValue(objList){
        alert(objList.value)
    }

    function findAllValues(objList){
        var text = "";
        for(var i=0; i<objList.length; i++){
            text += objList[i].value+", ";
        }
        alert(text);
    }
  </script>
 </HEAD>

 <BODY>
    <select id="list">
        <option value="One">One</option>
        <option value="two">two</option>
        <option value="Three">Three</option>
    </select> <br/>
<input type="button" value="Get Selected Index" onclick="findSelectedIndex(document.getElementById('list'))"><br/>
    <input type="button" value="Get Selected Value" onclick="findSelectedValue(document.getElementById('list'))"><br/>
    <input type="button" value="Get All Value" onclick="findAllValues(document.getElementById('list'))"><br/>

 </BODY>
</HTML>

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Shallow Copy Deep Copy Java example

Database Connection using NODE JS example