JavaScript: Getting the focus at the END of a textarea?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
MattSharp
Forum Commoner
Posts: 62
Joined: Wed Apr 24, 2002 2:25 pm

JavaScript: Getting the focus at the END of a textarea?

Post by MattSharp »

phpBB can do this, so I know it's possible. How do you get the the cursor to go to the end of a textarea not the beginning? Thanks.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

I always thought that that is automatic. If not, try:

document.myForm.myFormField.value=document.myForm.myFormField.value;

It simply pastes the text in the formfield into the formfield, thus overwriting the original text with an exact copy. Then the focus is definitely at the end of the textarea.
Post Reply