This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion 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

Placing Cursor at End of Text

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1563
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

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

Joined: Nov 08, 2001
Posts: 15385
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.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

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] [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:


I agree. Here's the link:
subject: Placing Cursor at End of Text
It's not a secret anymore!