freelance84 Posted July 27, 2010 Share Posted July 27, 2010 The following code in the body tag easily gets a cursor blinking in the desired form box when the page loads: onload="document.form_1.t_description_entry.focus() However, is it possible to get the cursor to jump the end of the text string in the said form box? (my knowledge on js is very basic at the moment, so apologies if this is an ultra basic question) Quote Link to comment https://forums.phpfreaks.com/topic/208994-cursor-to-the-end-of-a-string/ Share on other sites More sharing options...
Psycho Posted July 27, 2010 Share Posted July 27, 2010 Here is a bit of a hack, but it works in both IE and FF, did not try in other browsers: function setFocusToEnd(fieldID) { var inputObj = document.getElementById(fieldID); inputObj.focus(); inputObj.value = inputObj.value; } Then just call the onload event using onload="setFocusToEnd('t_description') Assuming you gave the field an ID and not just a name. Quote Link to comment https://forums.phpfreaks.com/topic/208994-cursor-to-the-end-of-a-string/#findComment-1091730 Share on other sites More sharing options...
freelance84 Posted July 29, 2010 Author Share Posted July 29, 2010 Ah cool cheers, I'll give that a bash. Thanks mjdamato Quote Link to comment https://forums.phpfreaks.com/topic/208994-cursor-to-the-end-of-a-string/#findComment-1092522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.