[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1097
  • Last Modified:

<textarea> insertion point cursor positioning

I use the following Javascript to place the insertion point cursor in a <textarea> when the page loads: self.document.myPage.myTextarea.focus(); This puts it at the first character in the <textarea>. Is thre a way to place it after the last character in the <textarea> when there is default text there and the user is to add to it?

0
vogtster
Asked:
vogtster
  • 2
  • 2
1 Solution
 
cLFlaVACommented:
Yup.

document.forms['myPage'].elements['myTextarea'].focus;
document.forms['myPage'].elements['myTextarea'].value += '';
0
 
cLFlaVACommented:
Whoa,

document.forms['myPage'].elements['myTextarea'].focus();
document.forms['myPage'].elements['myTextarea'].value += '';
0
 
k-doCommented:
You can modify your onload statement to the following:

self.document.form1.myTextarea.focus();self.document.myPage.myTextarea.value += '';

(Those are two single quotes at the end.)

Hope this helps,

Keith
0
 
k-doCommented:
Sorry - should've refreshed the page before I posted!  (and the form1 would've been myPage)

Keith
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now