Brainstorms of a Webdev

Web development, PHP, Security, etc… etc…

  • Home
  • About

5

May

Javascript Auto Focus Form Element

Posted by tarnus  Published in Javascript

One of the main reasons I decided to have this blog is to create a reference place so I could easily find code or how to do things from time to time. Usually I have to sift through code trying to remember the last place I used something. From here on out I plan on posting code snippets as I run across them. Today I woke up to an email requesting if a signup form or member login form was opened, they wanted the cursor to automatically focus on the username or the first element of the form. To be honest, I didn't even know it could be done from a page open. So the first thing I did was open up Google and search until I find a way. I an not too ego minded to think I know everything. There is always someone that has found a better way.

Here is the JavaScript code:

Here is the XHTML part of the code:

 
<form>
<input id="element" />
<input />
<input />
</form>
 

For those that are a little new to javascript. The javascript should go in the document HEAD. The "element" can be changed to the id of the field you are working with.

no comment

Search

Get Support

Categories

  • Domain Names (1)
  • Electronics (1)
  • Javascript (1)
  • mysql (1)
  • PHP (4)
  • Template Lite (2)
  • Uncategorized (1)

Archives

  • May 2008
  • April 2008

Blogroll

  • Alien Assault Traders
  • Diana Botsford
  • Oznet
  • Sonnar Internet
  • Springfield Net

RSS Twitter: tarnus

  • Oh...waiting always sucks when your busy 09:05:17 AM May 23, 2008 from txt
  • Why do people refuse to listen 04:00:34 PM May 19, 2008 from im
  • Back to work... its a Monday 10:51:08 AM May 19, 2008 from im
  • Nothing like kids with nothing better to do than mess with my servers to ruin my sleep 12:52:10 AM May 18, 2008 from im
  • I got to get in better shape...I hate feelin winded 05:23:05 PM May 17, 2008 from txt

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
September 2008
M T W T F S S
« May    
1234567
891011121314
15161718192021
22232425262728
2930  

Recent Post

  • sql file splitter to the rescue
  • Palm Centro, my new phone
  • PHP day count and date comparison
  • Experiments in Domain Parking
  • Javascript Auto Focus Form Element
  • Variable Variables and Template Lite
  • Template Lite Modifiers

Recent Comments

  • Online Reviews » Blog Archive… in Palm Centro, my new phone
© 2007 Brainstorms of a Webdev
Theme by Wired Studios, courtesy of Corvette Garage
Valid XHTML | Valid CSS 3.0
Powered by Wordpress