471,853 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

Set cursor position to the end of a text field ?

Hi,
I can set focus on a text field. But the cursor is always stay at the
beginning , how to set the cursor at the end ?

Thank you.

Aug 10 '05 #1
2 27220
Who
"duzuike" wrote
I can set focus on a text field. But the cursor is always stay at
the beginning , how to set the cursor at the end ?

Thank you.


In some browsers, including IE and FF, the trick is to set the value of the
element after setting the cursor. The cursor will then be moved with it as
the new value is written and end up at the end...

tt.focus(); tt.value = tt.value;

Otherwise, you will need to manipulate text selection ranges, which is a
pain to do crossbrowser.
hth
ivo
http://4umi.com/
Aug 10 '05 #2
Thank you for your valuable reply. It works.

Aug 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by supportgeek | last post: by
1 post views Thread by Tantra Veda | last post: by
1 post views Thread by Paul | last post: by
1 post views Thread by =?Utf-8?B?anAybXNmdA==?= | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.