Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Select name

The name property returns the name of the select box. This property is accessed via the elements array of a Form object and used to return the name of the select area. <html>     <head>     <script language="JavaScript">     <!--     function getName(){       alert("The name of this select box is " + document.myForm.elements[0].name);     }     -->     </script>     </head>     <body>     <form name="myForm">       <select name="mySelect" multiple>         <option value=A>AA</option>         <option value=B>BB</option>         <option value=C>CC</option>         <option value=D>DD</option>       </select>       <input type=BUTTON value="Get Name" name="myButton" onClick='getName()'>     </form>     </body>     </html>