Page 1 of 1
Text box question
Posted: Mon Aug 25, 2003 6:18 pm
by oldtimer
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?
Posted: Mon Aug 25, 2003 7:03 pm
by JAM
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
Posted: Tue Aug 26, 2003 1:14 am
by gite_ashish
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>
Posted: Wed Aug 27, 2003 10:47 am
by oldtimer
I did not post it in client side as I was hopping there was a way to do it in PHP.
Posted: Wed Aug 27, 2003 11:26 am
by JAM
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.