Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Thanked 0 Times in 0 Posts

    Manipulating Caret/Cursor position in textboxes

    I need help manipulating the caret/cursor position in a textbox. It's actually for a 'virtual keyboard' that updates textbox content. The function will add text wherever the current position is (i.e., after hitting <, >, Home, End, etc), but I can't display the caret in that location.

    Suppose I've typed "TEST" with the virtual keyboard. The following function easily displays the caret at the end of the text, but trying to change the position leads to problems:

    function showCursor(field,len) {
    //Display caret/cursor at current position.
    if (document.myForm[field].createTextRange) {
    var r = document.myForm[field].createTextRange();
    r.moveStart('character', len);

    (*note 'len' refers to the current position.)
    This only keeps the caret at the end of the textbox string, and doesn't allow the keyboard function to update the position (ie, <, >). Any ideas? Thanks!
    Last edited by cstetson; 10-01-2003 at 12:54 AM.


Posting Permissions

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