wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Placing Cursor at End of Text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Placing Cursor at End of Text" Watch "Placing Cursor at End of Text" New topic
Author

Placing Cursor at End of Text

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
In my JSP pages I have input text boxes. When I use the mouse and click into these boxes the cursor does not automatically go to the first position and if text is already in the box the cursor does no go to the end.

Can this be fixed?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Moving to the HTML/Javascript forum where client side issues are discussed


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You have no control over this really since it is a browser implementation.

You can play with this code:



<input type="text" onfocus="SetCursorToEnd(this)">

Only issue is if comeone clicks on the field manually, it will not allow them to focus where they wanted to go.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Originally posted by Steve Dyke:
Can this be fixed?
It's not broken. That's the expected behavior.
[ August 21, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeff Horan
Ranch Hand

Joined: Apr 03, 2003
Posts: 37
Why can't a synthetic event fire and set the keycode to 35 (end) or 39 (right) and move a specific num of chars over? I'm trying that now, but I don't know about javascript events to get this to work. This is what I have so far:


Thanks


jh
 
jQuery in Action, 2nd edition
 
subject: Placing Cursor at End of Text
 
Similar Threads
HTML set focus after text in textbox
Position cursor at the end in textareas
What type of listener can i use, instead of FocusListener
Disable quick fixes in mouse over box in Eclipse 3.4.1? And increase delay before box is shown?
odd submit behavior with only one text box