File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes selecting text area at focus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "selecting text area at focus" Watch "selecting text area at focus" New topic

selecting text area at focus

Harry Chawla
Ranch Hand

Joined: Jun 03, 2000
Posts: 97
I was wondering if i can select the text area in a text box, whenever the that text box gets the focus; usingJavascript or DHTML.
Any suggestions will be highly appreciated.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Yeah, with the text boxes, have an onFocus event that does the following function:;
Or you can probably put the function right there in the code that says:
<input type="text" onFocus=";">
Haven't tried the second version, but may work.
[This message has been edited by bill bozeman (edited January 04, 2001).]
Harry Chawla
Ranch Hand

Joined: Jun 03, 2000
Posts: 97
Hi Bill
Thanks a lot for ur invaluable tips.
I tried the second version
and it works fine on IE. In netscape, it works fine if one uses keyboard but with mouse, it selects on the text on the left hand side from the point of click and doesn't select any text on righthandside. I'm still wondering if i can use something to work the same way on both these browsers.
BTW how good is the Javascript book by ORiely. I'd prefer to get a book preferable which has good stuff on both Javascript and DHTML. Do u have any recommenddation?
Thanks again.
I agree. Here's the link:
subject: selecting text area at focus
jQuery in Action, 3rd edition