How to place cursor at the last on textbox

Discussion in 'JavaScript' started by goodmast3r, Jun 10, 2011.

  1. #1
    I have tried everything, and it just dont work.

    temp = document.getElementById("test").value;
    document.getElementById("test").value = "";
    document.getElementById("test").value = temp;
    document.getElementById("test").focus();
    HTML:
    I tried that code. Seems like it move the cursor to the end of textbox, but I couldn't see the cursor blinking and moving to the end of the textbox.
     
    goodmast3r, Jun 10, 2011 IP
  2. goodmast3r

    goodmast3r Active Member

    Messages:
    1,220
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #2
    Anyone can help please?
     
    goodmast3r, Jun 12, 2011 IP
  3. Jan Novak

    Jan Novak Peon

    Messages:
    121
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    0
  4. goodmast3r

    goodmast3r Active Member

    Messages:
    1,220
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #4
    yes. but it didn't work if we have long text. see here http://odihost.com/test.php

    setCaretToPos(document.getElementById("YOURINPUT1"), 35); wont work, but setCaretToPos(document.getElementById("YOURINPUT1"), 4); will work
     
    goodmast3r, Jun 12, 2011 IP