Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Text In an Input Field

Status
Not open for further replies.

jsulman

Programmer
Jun 14, 2001
85
US
Greetings,
When tabing from one text field to another in an HTML form when you land on a field all the characters are automatically selected. I have a text field that is performing some function that "unselects" the text. Is there a way in JavaScript that I can programatically reselect all the characters in the field.

Thank You In Advance

Jeff Sulman
 
This is what I use...

Code:
function selectAll(inField){
    inField.focus();
    inField.select();
}

And the HTML should be:
Code:
<input type="text" value="Here is some text" onclick="selectAll(this)" />
 
Thank you MikeyJudd. That was waaaaaay to easy.

Jeff
 
You are certainly welcome! I have had to use that several times before. Also works in Text Areas...if you care, haha.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top