set focus on username while login..

Found a bug? Tell us!!
Post Reply
sweety
Regular
Posts: 42
Joined: Tue Jul 05, 2005 11:05 am

set focus on username while login..

Post by sweety »

hi all,
In the login page i have username and password ....as soon as the page is opened my cursor is not pointing towards the username field...but i want it to happen as soon as my login page is loaded...can this be done??
i tried to do as below...

Code: Select all


<script language="text/javascript"> 
   function func1() 
{ 
   document.f1.user[user1].focus(); 
} 
</script> 



<form name="f1" onload="func1()"> 
  <input type="text" name="user[user1]" > 
<input type="password" name="pass1"> 
</form> 

I also tried to put the onload function in body tag...but still its not working..
i identified that the problem is with the text box name (user[user1])...it is not taking the square brackets...if i change the text box name to normal name as "user" then its working fine....but me giving the name as user[user1] is important in my code....so, can i have a better solution to solve this problem..
Thanking you in advance
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: set focus on username while login..

Post by garvinhicking »

Hi!

This is easy.

1. Edit your serendipity_admin.php file
2. Go to line 45, within the spawn() function.
3. Within that function add this code:

Code: Select all

if (document.forms && document.forms[0] && document.forms[0].elements['serendipity[user]']) {
    document.forms[0].elements['serendipity[user]'].focus();
}
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
sweety
Regular
Posts: 42
Joined: Tue Jul 05, 2005 11:05 am

Post by sweety »

Hi garvin,
Thank you very much for ur help....it worked well
Post Reply