Solved

<textarea> insertion point cursor positioning

Posted on 2004-10-22
1,068 Views
Last Modified: 2008-03-17
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
Question by:vogtster
    4 Comments
     
    LVL 13

    Expert Comment

    by:cLFlaVA
    Yup.

    document.forms['myPage'].elements['myTextarea'].focus;
    document.forms['myPage'].elements['myTextarea'].value += '';
    0
     
    LVL 13

    Accepted Solution

    by:
    Whoa,

    document.forms['myPage'].elements['myTextarea'].focus();
    document.forms['myPage'].elements['myTextarea'].value += '';
    0
     
    LVL 3

    Expert Comment

    by:k-do
    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
     
    LVL 3

    Expert Comment

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

    Keith
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Foundations of Front-End Development

    Jump-start a lucrative career in front-end web development, with zero previous coding experience required. This course covers the basic programming concepts and languages required for creating engaging websites from scratch.

    In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now