Page 1 of 1
JS Selstart?
Posted: Tue Jun 22, 2004 10:25 am
by Joe
I was trying to look for a javascript reference that tells me how to selstart a text box. Im sure that 'selstart' is the name for it. What it does is when the user visits the page it automatically puts the text pointer into the username text field. i have seen it in action before but I just can't seem to do it myself. Can anyone please guide me in the right direction here?
Any help appreciated!
Joe

Posted: Tue Jun 22, 2004 10:36 am
by markl999
I usually just put the following after the closing </form> tag :
<script language="JavaScript">document.aform.atitle.focus();</script>
Where 'aform' is the name of the form and 'atitle' is the field to get focus. Eg
Code: Select all
<form name="aform" method="post">
<input type="text" name="atitle" value="" />
</form>
<script language="JavaScript">document.aform.atitle.focus();</script>
Posted: Tue Jun 22, 2004 10:39 am
by Illusionist
Code: Select all
<script>
<!--
function sf(){document.form_name.textbox_name.focus();}
// -->
</script>
and then
form_name is the name of your form that the textbox is in
textbox_name is the name of the textbox or any control that you want to set the focus for.
Posted: Tue Jun 22, 2004 10:45 am
by Joe
Very nice indeed

. Thanks alot guys, problem solved. hehe