how to get multiple select values in javascript

//Here client is id of multiple dropdown….

<select multiple=”multiple” id=”client” >
<option value=’1′>1</option>
<option value=’2′>2</option>
<option value=’3′>3</option>
</select>

<input type=’button’ value=’Test’ onclick=’tes()’>

<script type=’text/javascript’>

function tes()

{
var cnt=document.getElementById(‘client’).length;
      var arr=new Array();
      var j=0;
      for(var i=0;i<cnt;i++)
      {
        if(document.getElementById(“client”).options[i].selected == true)
        {
            arr[j]=document.getElementById(‘client’).options[i].value;
            j++;
        }
      }

alert(arr.length);

}

</script>


Comments

One response to “how to get multiple select values in javascript”

Leave a Reply

Your email address will not be published. Required fields are marked *