Web Analytics Made Easy -
StatCounter onclick focus cursor after the text in the textarea box - CodingForum

Announcement

Collapse
No announcement yet.

onclick focus cursor after the text in the textarea box

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • onclick focus cursor after the text in the textarea box

    hi I was working on comments module where i pull of the usernames and insert them into a text area when i click a button.
    Now I want the cursor to point to the end of the username everytime i click the button. I tried using the focus() property but it takes me to the beginning of the text area.
    here is my code so far:


    Code:
    <script type="text/javascript">
    	function setComments(userID) {
    	    document.getElementById("comments_content").value = document.getElementById("comments_content").value + userID + "\n\n";
    	}
    </script>
    Code:
    <a onclick="setComments('<?php print $comment_username; ?>') + document.edit.comments_content.focus()" href="#addcomment">
       <img src="images/reply-button.png" align="top" border="0">
    </a>
    Code:
    <textarea class='comment-input-textarea-loggedin'  id='comments_content' name='comments_content'></textarea>

  • #2
    See this topic: http://www.codingforum.net/showthread.php?t=235907
    Descript.org - lightweight JavaScript foundation framework

    Comment

    Working...
    X