Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-08-2003, 12:23 AM   PM User | #1
ventura
New Coder

 
Join Date: Jul 2002
Location: Noblesville, IN
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
ventura is an unknown quantity at this point
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
ventura is offline   Reply With Quote
Old 07-08-2003, 12:57 AM   PM User | #2
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
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.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 07-08-2003, 01:05 AM   PM User | #3
ventura
New Coder

 
Join Date: Jul 2002
Location: Noblesville, IN
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
ventura is an unknown quantity at this point
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
ventura is offline   Reply With Quote
Old 07-08-2003, 09:46 AM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
There's method setEndPoint but... hm, I never use it... I am not sure that it might help you...
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:18 AM.


Advertisement
Log in to turn off these ads.