Re: Quick questions -- how do I place the cursor (i.e., set focus) to a field on page load?

From: Date: Wed, 14 Nov 2007 01:36:14 +0000
Subject: Re: Quick questions -- how do I place the cursor (i.e., set focus) to a field on page load?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-264463@lists.php.net to get a copy of this message
Jon Westcot wrote:
Hi Mike:
you want javascript. i'd recommend using jquery (jquery.com)
    I'll look into this.  Thanks.
put an id="username" on the username box. then do <script type="text/javascript"> $(document).ready(function() { $("#username").focus(); }); </script> voila
    Hmmm.  It didn't work for me.  Do I need to change any of the code you
provided or should it work as you wrote it?
It only works if you have included the jquery javascript files. If you don't want to use that you could do something like: <script defer> document.getElementById('username').focus(); </script> -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#264463) next »