Jump to content

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>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.