[SOLVED]How to focus cursor in textfield on page load PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

[SOLVED]How to focus cursor in textfield on page load PHP

Post by Calimero »

When the page is laoded my visitors must click on the textfield to enter the search string.
How to automatise it, when the page loads you only need to type (because the cursor is in the the first textfield on the page)

Is this better done troug PHP or javascript...Better way no matter which is if possible.

Thanks ahead.[/big_search]
Last edited by Calimero on Tue Jun 15, 2004 5:32 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

only javascript would be able to do this..

you need to focus() the field onload.. like this:

Code: Select all

<body onload="document.forms.formname.fieldname.focus()">

<form name="formname"><input type="text" name="fieldname"></form>
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

I'll try it thanks, THIS SHORE WAS QUICK

Post by Calimero »

AND SOMETHING IN THE BODY ... :D
Post Reply