php_begins Posted August 23, 2011 Share Posted August 23, 2011 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> Link to comment https://forums.phpfreaks.com/topic/245511-onclick-focus-cursor-after-the-text-in-the-textarea-box/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.