Need help with textbox...

Discussion in 'JavaScript' started by x0x, Feb 1, 2009.

  1. #1
    Is it possible to have the textbox selected for typing when visiting a page?

    So when I go on the page, I wouldn't have to click on the textbox, I could just write.
     
    x0x, Feb 1, 2009 IP
  2. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #2
    OK, found the focus code bit..

    The problem:

    if the box already has data, in IE the cursor will start blinking in the beginning of the text (good for me), but in firefox it starts blinking in the end of the text, is there a way to make it be in the beginning for both?
     
    x0x, Feb 1, 2009 IP
  3. lp1051

    lp1051 Well-Known Member

    Messages:
    163
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
  4. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Hello. I think the page you gave me and this page:
    http://blog.josh420.com/archives/20...in-a-textbox-or-textarea-with-javascript.aspx

    Have all the answers I need, but I don't know how to use that code. I don't know much about java, I couldn't get it to work...

    Right now I have
    <script type="text/javascript">
    function setFocus(){
    document.getElementById("message").focus();
    
    }
    </script>
    PHP:
    and

    <body onLoad="setFocus()">
     
    x0x, Feb 2, 2009 IP