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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    134
    Thanks
    20
    Thanked 0 Times in 0 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
    New to the CF scene
    Join Date
    Aug 2011
    Location
    Poland
    Posts
    8
    Thanks
    0
    Thanked 2 Times in 2 Posts


  •  

    Tags for this Thread

    Posting Permissions

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