JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next Method

Name Method---select the text in form element


Navigator 2.0, Internet Explorer 3.0







The select() method selects the text displayed in a Text, Textarea, Password, or FileUpload element. The effects of selecting text may vary from platform to platform, but typically invoking this method produces the same effect as if the user had dragged the mouse across all the text in the specified Text object. On most platforms, this produces the following effects:

The user can usually deselect text by clicking in the Text object or by moving the cursor. Once deselected, the user can add and delete individual characters without replacing the entire text value.


Selecting a string in a Text object like this can be useful when you want to allow the user to accept the string as it is or to replace it entirely and enter a new value from scratch.


On Unix platforms in Navigator 2.0 and 3.0, the select() method only works for the Text element, and not for the Textarea, Password or FileUpload elements.

See Also


Previous Home Next
Element.options[] Book Index Element.selectedIndex

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
Hosted by uCoz