Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Noblesville, IN
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    focus cursor at certain position inside textarea

    is there a way to set the cursor to be at a certain point in a text area when the page is loaded?

    i have a prefilled text area and want the cursor to show up after the text inside of it.

    Code:
    <html>
      <body>
         <form name="form1" id="form1">
              <textarea name="field1" cols="60" rows="10" id="field1">I want the cursor to show up after this line. </textarea>
         </form>
      </body>
    </html>
    Ed Ventura
    Graphic/Web Designer
    www.blackwatercompany.com

  • #2
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Assume "tarea" is a reference to the textarea:

    tarea.setSelectionRange(tarea.length, tarea.length);

    This is for Gecko-based browsers, such as Mozilla, Firebird, NS7, Camino, etc.

    There is some way using a TextRange object in Win/IE of doing this, but I don't recall it off the top of my head.

  • #3
    New Coder
    Join Date
    Jul 2002
    Location
    Noblesville, IN
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks. IE is actually the browser that i'm targeting. if anyone knows how to do this in IE, i'd appreciate it.
    Ed Ventura
    Graphic/Web Designer
    www.blackwatercompany.com

  • #4
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    There's method setEndPoint but... hm, I never use it... I am not sure that it might help you...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •