Hello, A few weeks ago I've written a small plugin for that: $.fn.fieldFocus = function(id){ document.getElementById(id).focus(); }
and you call it using: $(document).fieldFocus("the_id_of_the_input_field_without_#"); 2006/11/17, Clodelio Delfino <[EMAIL PROTECTED]>: > > Thanks Erik for the input, got the culprit...when thickbox is used, the > modal/dialog box link clicked doesn't fire-up the onload event which is the > reason why focus() doesn't work... c",) > > anyway, i've created a link without using thickbox and just do plain CSS, > it now works! > > Thanks again for the help... > > cheers, > cdelfino > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Erik Beeson > Sent: Friday, November 17, 2006 10:36 AM > To: jQuery Discussion. > Subject: Re: [jQuery] input field focus help! > > Ahh, right, that is the right code, but it doesn't work in > $(document).ready(...). I do it like this: > > setTimeout(function() {$('#username').get(0).focus();}, > 250); > > Inside $(document).ready(...). Maybe moving it to load or something would > work better. Haven't tried yet. > > --Erik > > > On 11/16/06, Clodelio Delfino <[EMAIL PROTECTED]> wrote: > > > > > > Thanks Erik for the input but it doesn't work... c",) > > > > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Erik Beeson > > Sent: Friday, November 17, 2006 7:34 AM > > To: jQuery Discussion. > > Subject: Re: [jQuery] input field focus help! > > > > .focus() does NOT set the focus of an element, it fires all of the > registered onfocus events. Use $("").get(0).focus(). > > > > --Erik > > > > > > On 11/16/06, Clodelio Delfino <[EMAIL PROTECTED]> wrote: > > > i've downloaded thickbox and tried the login demo, the dialog box work > as > > > expected however but when i tried to set an autofocus on the username > field, > > > it doesn't work. > > > > > > below is a snippet of the code: > > > > > > default.php has the clickable: > > > > > > <a href="login.php?height=200&width=300" class="thickbox" title="Please > > > Login">Click Login</a> > > > > > > > > > login.php is the form with code below: > > > > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> > > > <html xmlns="http://www.w3.org/1999/xhtml"> > > > <head> > > > <title>Test Only</title> > > > <meta http-equiv="content-type" > content="text/html;charset=utf-8"> > > > <script type="text/javascript" > > > src="./libraries/jquery-latest.pack.js"></script> > > > <script type="text/javascript"> > > > $(document).ready(function() { > > > /*$("#frmLogin > [EMAIL PROTECTED]'frmUsername']").attr('disabled',true)*/ > > > /* just to test that im correctly referencing the correct field */ > > > $("#frmLogin > [EMAIL PROTECTED]'frmUsername']").focus() > > > }) > > > </script> > > > </head> > > > <body> > > > <!-- Section:Content --> > > > <div id="divContent"> > > > <form id="frmLogin" method="post" action="check_credential.php"> > > > <table class="tblForm"> > > > <caption> </caption> > > > <tr> > > > <td class="frmField">ID Number</td> > > > <td class="frmInput"><input name="frmUsername" type="text" > size="20" > > > maxlength="20" /></td> > > > </tr> > > > <tr> > > > <td class="frmField">Password</td> > > > <td class="frmInput"><input name="frmPassword" type="password" > > > size="20" maxlength="20" /></td> > > > </tr> > > > <tr> > > > <td> </td> > > > <td class="frmInput"> > > > <input name="btnLogin" type="submit" value="Login" /> > > > </td> > > > </tr> > > > </table> > > > </form> > > > </div> > > > <!-- [Section:Content] --> > > > </body> > > > </html> > > > > > > > > > Need inputs and thanks in advance.... > > > > > > > > > cdelfino > > > > > > > > > > > > _______________________________________________ > > > jQuery mailing list > > > discuss@jquery.com > > > http://jquery.com/discuss/ > > > > > > > > > _______________________________________________ > > jQuery mailing list > > discuss@jquery.com > > http://jquery.com/discuss/ > > > > > > > > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > > > -- Roberto Ortelli http://weblogger.ch _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/