SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Form Field Focus
-
Nov 11, 2007, 10:04 #1
- Join Date
- Nov 2004
- Location
- England
- Posts
- 702
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
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
-
Nov 11, 2007, 10:14 #2
- 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
-
Nov 11, 2007, 10:28 #3
- 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