I have heard there is a way to put the curser in a certain text box automatically so that the end user does not have to click in the text box.
I have seen some javascript that will put it in the first field but if I have several and want that one then this script will not work.
Any ideas?
Text box question
Moderator: General Moderators
1. Should be posted in ClientSide part of this forum...
2. You can still use Javascript. Use it as a function on top of the page, and the call it in the text-field of choise using the onload() event or similiar.
More info on the net
2. You can still use Javascript. Use it as a function on top of the page, and the call it in the text-field of choise using the onload() event or similiar.
More info on the net
- gite_ashish
- Forum Contributor
- Posts: 118
- Joined: Sat Aug 31, 2002 11:38 am
- Location: India
I guess, you are looking for following:
<HTML>
<BODY onLoad="document.frm.txt1.setFocus();"> <!-- ** ** -->
<FORM name=frm>
First nane: <INPUT type=text name=txt1>
Second name: <INPUT type=text name=txt2>
House #: <INPUT type=txt name=txt3>
Street #: <INPUT type=txt name=txt4>
<INPUT type=submit>
</FORM>
</BODY>
</HTML>
<HTML>
<BODY onLoad="document.frm.txt1.setFocus();"> <!-- ** ** -->
<FORM name=frm>
First nane: <INPUT type=text name=txt1>
Second name: <INPUT type=text name=txt2>
House #: <INPUT type=txt name=txt3>
Street #: <INPUT type=txt name=txt4>
<INPUT type=submit>
</FORM>
</BODY>
</HTML>
Still yes and no. (For others that might read the post:)
As gite_ashish pointed out, a body's onload would solve it.
PHP can in this case be used for example; counting the amount of form-fields shown, and give you a number/name of a field you might want to set focus to.
But as PHP does not do anything with the visual states, Javascript is needed to do the actual focusing. PHP is server-side, so you can in theory only set the focus on the server, if there was anything to focus on... =)
Hope it helped tho.
As gite_ashish pointed out, a body's onload would solve it.
PHP can in this case be used for example; counting the amount of form-fields shown, and give you a number/name of a field you might want to set focus to.
But as PHP does not do anything with the visual states, Javascript is needed to do the actual focusing. PHP is server-side, so you can in theory only set the focus on the server, if there was anything to focus on... =)
Hope it helped tho.