File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

selecting text area at focus

Harry Chawla
Ranch Hand

Joined: Jun 03, 2000
Posts: 97
Hi
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.
Thanks.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Yeah, with the text boxes, have an onFocus event that does the following function:
document.form_name.field_name.select();
Or you can probably put the function right there in the code that says:
<input type="text" onFocus="javascript:this.select();">
Haven't tried the second version, but may work.
Bill
[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
onFocus="javascript:this.select();"
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: http://aspose.com/file-tools
 
subject: selecting text area at focus
 
Similar Threads
Javascript
Accessibility
Cant show an object which extends JPanel in the form?
XHTML based editor on a servlet based application?
Accessibility