Determining the Values of Multiselection Lists : List : Form Control JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Form Control » List »

 

Determining the Values of Multiselection Lists



<html>
<head>
<script language = "JavaScript">
     function showSelection(objectName) {
          var list = ""
          for (var i=0; i<objectName.length; i++) {
               if (objectName.options[i].selected) {
                    list += objectName.options[i].text + "<p>"
               }
          }
          alert(list)
     }
   
</script>
</head>
<body>
    <form name="form1">
      Pick Your Favorite Songs From the List:<p>
        <select NAME="songs" SIZE=MULTIPLE>
            <option>AA</option>
            <option>B</option>
            <option>C</option>
            <option>D</option>
            <option>E</option>
            <option>F</option>
            <option>G</option>
            <option>H</option>
            <option>I</option>
            <option>J</option>
        </SELECT><p>
      <input type=button value="Show Selection" onClick="showSelection(this.form.songs)">
    </form>
</body>
</html>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Form Control
» List