Page 1 of 1

set focus on username while login..

Posted: Fri Oct 14, 2005 7:57 am
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

Re: set focus on username while login..

Posted: Fri Oct 14, 2005 2:15 pm
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

Posted: Fri Oct 14, 2005 5:28 pm
by sweety
Hi garvin,
Thank you very much for ur help....it worked well