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 How to place the cursor at the end of a textfield Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "How to place the cursor at the end of a textfield" Watch "How to place the cursor at the end of a textfield" New topic
Author

How to place the cursor at the end of a textfield

Rhea Karnam
Greenhorn

Joined: May 06, 2003
Posts: 21
Hi,
I have a text field with some data already entered in it, and i want to let the user to append more characters to the textfield. So, when he/she clicks on a button "Append data", i have written a javascript that sets the focus to the textfield (tf.focus). But, the cursor is placed at the first character. Is there some way to place the cursor after the last character?
I am left clueless. I found some help on the web, but that is browser specific.
Rhea
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
Netscape usually places the cursor at the end, IE code which you prob. found focus the field, creates a text range, and collasps it and cause the cursor to be at the end. I would post the code, but i need to leave for work in 2 minutes
Eric
 
 
subject: How to place the cursor at the end of a textfield
 
Threads others viewed
Text out of displayed region
Browser does not call the stop() method.
JFormattedTextField using NumberFormatter ?
transfering focus with enter key
Trapping keys in java applet
IntelliJ Java IDE