1
El_Jordo
Automatically bring focus to username text box
  • 2004/2/16 19:55

  • El_Jordo

  • Just popping in

  • Posts: 64

  • Since: 2003/4/23


I'd like the username box (in the login block) to receive the focus after loading, much like the Google search box automatically receives the focus on that page. That way, my users could simply type username-tab-password-enter, without having to first click inside the username box.

I've examined the source code of many pages, including Google, but I can't seem to make it work precisely. It looks like I need a snippet of javascript in the theme.html file. Could somebody lend me a hand?

Thanks!

2
hsalazar
Re: Automatically bring focus to username text box
  • 2004/2/16 23:30

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


El_Jordo:

The principle is this. Edit the template of the login block to assign names to the form and the input field. In this case, since the input field is already named "uname", you don't need to add more than the following (I've marked in red the addition, and show only the beginning of the file):
Quote:

<form name="myForm" style="margin-top: 0px;" action="<{$xoops_url}>/user.php" method="post">
<{$block.lang_username}><br />
<input type="text" name="uname" size="12" value="<{$block.unamevalue}>" /><br />...


Now you need to open theme.html and add, to the body tag, the following sentence:

Quote:

onLoad="document.myForm.uname.focus()"


I thinks that's all...

Cheers.

3
El_Jordo
Re: Automatically bring focus to username text box
  • 2004/2/16 23:41

  • El_Jordo

  • Just popping in

  • Posts: 64

  • Since: 2003/4/23


That worked perfectly. Thank you!

Login

Who's Online

230 user(s) are online (149 user(s) are browsing Support Forums)


Members: 0


Guests: 230


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits