Infolinks In Text Ads

Jul 24, 2010

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>

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...