Forums
This topic is locked
cursor position
Posted 11 Sep 2002 03:14:58
1
has voted
11 Sep 2002 03:14:58 Angela Zhou posted:
I have a log in page where user inputs username and password, and i want the cursor to appear in the username textfield when the user loads that page, how do i do this?Thanks!
itsmicky
Replies
Replied 12 Sep 2002 20:20:57
12 Sep 2002 20:20:57 Ken Dobson replied:
After the </body> put the following:
<script type="text/javascript">
<!--
document.form1.username.focus();
//-->
</script>
Form1 is whatever the name of your form is, and username is the name of the field you want to set the focus to.
If this doesn't work for you, try the OnPageLoad event.
-Ken
<script type="text/javascript">
<!--
document.form1.username.focus();
//-->
</script>
Form1 is whatever the name of your form is, and username is the name of the field you want to set the focus to.
If this doesn't work for you, try the OnPageLoad event.
-Ken
Replied 12 Sep 2002 20:40:17
12 Sep 2002 20:40:17 Angela Zhou replied:
Hi Ken,
I am using ASP, the Java script seems not recognizable. (I inserted the codes but a runtime error says "document.form.fieldname.... is null or not an object"
Any suggestion? Thanks!!!
Itsmicky
I am using ASP, the Java script seems not recognizable. (I inserted the codes but a runtime error says "document.form.fieldname.... is null or not an object"

Any suggestion? Thanks!!!
Itsmicky
Replied 12 Sep 2002 20:49:48
12 Sep 2002 20:49:48 Ken Dobson replied:
What's the name of your form that the fields are sitting inside of called? What's the name of the field that you want to set the focus to?
Paste the code in a message and let us see what you have.
Paste the code in a message and let us see what you have.
Replied 12 Sep 2002 23:19:25
12 Sep 2002 23:19:25 Angela Zhou replied:
The code is here:
<form name="deptlog" method="post" action="<%=MM_LoginAction%>">
<p> </p>
<table width="75%" border="0" cellpadding="1" align="center" height="177">
<tr>
<td height="37">
<div align="right"><font color="#330066" size="3" face="Verdana, Arial, Helvetica, sans-serif">username</font></div>
</td>
<td height="37"> <font face="Verdana, Arial, Helvetica, sans-serif" color="#330066">
<input type="text" name="dept_user" size="20">
</font></td>
</tr>
<tr>
<td height="39">
<div align="right"><font color="#330066" size="3" face="Verdana, Arial, Helvetica, sans-serif">password</font></div>
</td>
<td height="39"> <font face="Verdana, Arial, Helvetica, sans-serif" color="#330066">
<input type="password" name="dept_pswd" size="20">
</font></td>
</tr>
<tr>
<td height="59"><font face="Verdana, Arial, Helvetica, sans-serif" color="#330066"></font></td>
<td height="59"> <font face="Verdana, Arial, Helvetica, sans-serif" color="#330066">
<input type="image" border="0" name="login" src="../Images/but_login.gif" width="113" height="39">
</font></td>
</tr>
</table>
</form>
Edited by - Itsmicky on 12 Sep 2002 23:20:54
<form name="deptlog" method="post" action="<%=MM_LoginAction%>">
<p> </p>
<table width="75%" border="0" cellpadding="1" align="center" height="177">
<tr>
<td height="37">
<div align="right"><font color="#330066" size="3" face="Verdana, Arial, Helvetica, sans-serif">username</font></div>
</td>
<td height="37"> <font face="Verdana, Arial, Helvetica, sans-serif" color="#330066">
<input type="text" name="dept_user" size="20">
</font></td>
</tr>
<tr>
<td height="39">
<div align="right"><font color="#330066" size="3" face="Verdana, Arial, Helvetica, sans-serif">password</font></div>
</td>
<td height="39"> <font face="Verdana, Arial, Helvetica, sans-serif" color="#330066">
<input type="password" name="dept_pswd" size="20">
</font></td>
</tr>
<tr>
<td height="59"><font face="Verdana, Arial, Helvetica, sans-serif" color="#330066"></font></td>
<td height="59"> <font face="Verdana, Arial, Helvetica, sans-serif" color="#330066">
<input type="image" border="0" name="login" src="../Images/but_login.gif" width="113" height="39">
</font></td>
</tr>
</table>
</form>
Edited by - Itsmicky on 12 Sep 2002 23:20:54
Replied 12 Sep 2002 23:38:35
12 Sep 2002 23:38:35 Ken Dobson replied:
Hmm. I just tried this with your code and it worked fine on my end.
<script type="text/javascript">
<!--
document.deptlog.dept_user.focus();
//-->
</script>
Make sure this goes after your </body> code.
<script type="text/javascript">
<!--
document.deptlog.dept_user.focus();
//-->
</script>
Make sure this goes after your </body> code.
Replied 12 Sep 2002 23:43:16
12 Sep 2002 23:43:16 Angela Zhou replied:
It's working now!!! <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
Thank you buddy!
Thank you buddy!