Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Stupid question

  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    108
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Stupid question

    Ok this is a stupid question but I am drawing a blank and im sure it is HTML related and not JS. Anyway what I am trying to remember is, how do I set the cursor to be in a text box in a form when the page loads?
    Thanks alot for the help

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,718
    Thanks
    0
    Thanked 240 Times in 235 Posts
    Hi there wayne3503,

    does this help...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript">
    window.onload=function() {
       document.forms[0][0].focus();
     }
    </script>
    
    </head>
    <body>
    
    <form action="#">
    <div>
    <input type="text"/>
    </div>
    </form>
    
    </body>
    </html>
    coothead

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    108
    Thanks
    0
    Thanked 2 Times in 2 Posts
    OMG coot can I not get rid of you? Not that I want to, this is crazy8 thanks coot....again

  • #4
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,718
    Thanks
    0
    Thanked 240 Times in 235 Posts
    Hi there wayne3503 a.k.a. crazy8,
    ...can I not get rid of you?
    You could try putting out a contract on me?
    Don't you know anyone from the mob?

    coothead

  • #5
    Regular Coder
    Join Date
    Jul 2007
    Posts
    108
    Thanks
    0
    Thanked 2 Times in 2 Posts
    actually...in highschool i knew a student who was in russsian mob....anyway thank you for the help ill give it a try and see if it helps. It does look like what i think I need. The sad thing is I have done it before and cant find the code where I thought I had used it.
    Though I thought it was something that got inserted into the <body> tag. Guess I was wrong...

  • #6
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,718
    Thanks
    0
    Thanked 240 Times in 235 Posts
    Hi there crazy Wayne,
    I thought it was something that got inserted into the <body> tag. Guess I was wrong.
    No, you were not wrong.
    It is just better practice to remove to remove javascript event handlers from the markup.

    coothead

    p.s. I will have to keep my open for Russians from now on. Don't seem to get that many in my neck of the woods, though.

  • #7
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    We don't want to Russia, but if you Moscow.................
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.


  •  

    Posting Permissions

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