台湾综艺谈步步惊心:登陆界面用户名的text如何获得焦点,代码加在什么位置

来源:百度文库 编辑:中科新闻网 时间:2024/05/05 22:43:04
<html>
<head>
<%
dim rstUser,uid,pwd

if request.QueryString("oper")="login" then
uid=request.Form("user_id")
pwd=request.Form("password")
set rstUser=server.CreateObject("adodb.recordset")
rstUser.open "select * from users where user_id='"&uid&"'",conn
if not rstUser.eof then
if pwd=rstUser("psw") then
session("user_id")=uid
session("psw")=pwd
session("power")=rstUser("power")
session("user_name")=rstUser("user_name")
response.Redirect("admin/news/news_list.asp")
else

response.Write("<script language='javascript'>alert('密码错误?!');history.go(-1);</script>")
'response.Redirect("login.asp")
end if
else
response.Write("<script language='javascript'>alert('用户名错误!');history.go(-1);</script>")
'response.Redirect("login.asp")
end if

end if

%>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>login</title>
<link rel="stylesheet" href="css.css" type="text/css">

<script language="javascript">
function checktxt()
{
if(document.Login.user_id.value.length == "")
{
alert('请输入用户名!');
document.Login.user_id.focus();
return false;
}
if(document.Login.password.value.length == "")
{
alert('请输入密码!');
document.Login.password.focus();

return false;
}
return true;
}
</script>
</head>

<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">
<table border="0" cellpadding="0" cellspacing="0" align="center" >
<tr>
<td height="100" width="100%" align="center" valign="bottom">用户登陆</td>
</tr>
<tr>
<td>
<form name="Login" action="Login.asp?oper=login" onSubmit="return checktxt();" method="post">
<table width="250" height="155" align="center" border="0" >
<tr><td>用户名</td>
<td><input type="text" name="user_id" >
</td>
</tr>
<tr><td>密 码</td>
<td><input type="password" name="password"></td>
</tr>
<tr><td height="49" colspan="2" align="center"><input type="submit" name="submit" value="确定">  <input type="reset" name="reset" value="重置"></td></tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
登陆界面一加载,用户名的文本框获得焦点

body改成这个就可以了
<body onload="document.Login.user_id.focus();" leftmargin="0" rightmargin="0" topmargin="0"
bottommargin="0">

document.form名.text名.onfocus();