Jump to content

onclick focus cursor after the text in the textarea box


php_begins

Recommended Posts

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:

 

 

<script type="text/javascript">
function setComments(userID) {
    document.getElementById("comments_content").value = document.getElementById("comments_content").value + userID + "\n\n";
}
</script>

 

<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>

 

<textarea class='comment-input-textarea-loggedin'  id='comments_content' name='comments_content'></textarea>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.