SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Form Field Focus

    I know this will have been covered somewhere before but the search tool isn't working for me so apologies.

    I have used JS before to force focus onto the first field in a form, what ever that field or form may be called. I can't remember how I did it though so wondered if someone can refresh my memory?

    Thanks

  2. #2
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put this in your <head>:
    Code Javascript:
    window.onload = function(){
      document.getElementById('theField').focus();
    }

    On a page that contains an input field with an id called "theField".

    Hope that helps

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ah, you see this I've found already, I did it previously where it did it on ANY form on the first field, independently of the name/id. I stuck it in the head of a master page so all forms have the first field automatically selected. It's for a web-app rather than a normal site


Bookmarks

Posting Permissions

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