Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Text select()

The select() method selects the text in the text box. <html>     <head>     <script language="JavaScript">     <!--     function selectText(){       document.myForm.myText.select();       document.myForm.myText.focus();     }     -->     </script>     </head>     <body>     <form name="myForm">       <input type=TEXT value="hello world" name="myText">       <input type=BUTTON value="Click to Select Text" name="myButton" onClick="selectText()">     </form>     </body>     </html>