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 00:07:44 +0000
Subject: Re: Quick questions -- how do I place the cursor (i.e., set focus) to a field on page load?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-264458@lists.php.net to get a copy of this message
you want javascript. i'd recommend using jquery (jquery.com) put an id="username" on the username box. then do <script type="text/javascript"> $(document).ready(function() { $("#username").focus(); }); </script> voila On 11/13/07, Jon Westcot <jon@westcot.net> wrote: > Hi all: > > This may or may not be a PHP-related question, but, since I'm coding with PHP, I > thought I'd ask: > > When a form loads, such as a login form, I'd like to have the cursor placed > automatically in the Username field. Right now, it requires me to click it with the mouse or to tab > into it. I know I've seen this type of cursor control accomplished on countless web pages, but > I can't find any hints on how to accomplish this on my own. Can one of you wonderful code > wizards point me in the right direction? > > Also, while I'm asking questions, let me ask another one: I've seen several pages > (frequently, pages that come up after a login page has been filled out) that provide some user > mollification (you know, the typical "Please be patient, don't get your nylons in a knot, > we're typing as fast as we can" message), often with some type of moving text or graphics > (probably an animated GIF) that then goes away after a certain time and a third page is displayed. > I know that the headers("Location") code can do this, but I was under the (probably > mistaken) impression that this will NOT work if information has already been displayed on the page. > If that's the case, how are these other pages doing this? Knowing how to move from page to > page this way would really be helpful. > > Thanks so much. > > Jon >

« previous php.general (#264458) next »