Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Option value

The value property specifies the value that is returned to the server when the option is selected and the form is submitted. <html>     <head>     <title> Example of the text value of the option object</title>     </head>     <body>     <script language="JavaScript">     <!--     function getValue(myForm){        for (var i = 0; i < document.form1.myList.length; i++) {           if (document.form1.myList.options[i].selected == true) {              alert("The selected value is: " + document.form1.myList.options[i].value);           }        }     }     -->     </script>     <form name=form1>     <select name="myList" multiple>     <option value=1>One     <option value=2>Two     <option value=3>Three     <option value=4>Four     </select><P>     <input type="button" value="Get Value" onClick='getValue(this.form)'>     </form>     </body>     </html>