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 Placing Cursor at End of Text 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 "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: 1446
    
    1
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: 61220
    
  66

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Placing Cursor at End of Text