为什么下面代码加了表单运行不了

ljm19891118 2009-12-25 08:29:20
为什么下面代码加了表单运行不了
表单去掉就可以运行了
谁帮忙修改下
初学这不会改了


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登陆</title>
</head>

<script language="javascript">
function check()
{
if((document.tt.user.value=="zhangsan") &&(documeng.tt.psd.value=="123"))
location.href="logok.html";
else
window.alert("错误");
}
</script>


<body>
<form id="tt" name="tt" method="post" >
<table border="0" align="center">
<tr>
<td>用户名:</td>
<td> <input name="user" type="text" id="user" />
</td>
</tr>
<tr>
<td>密码:</td>
<td> <input name="psd" type="password" id="psd" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="Submit" value="登陆" onclick="check();" /> </td>
</tr>
</table>
<table border="0" align="center">
</form>
</body>
</html>
...全文
60 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ITDC_YiWang 2009-12-25
  • 打赏
  • 举报
回复


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登陆</title>
</head>

<script language="javascript">
function check(){
if((document.forms['tt'].user.value=="zhangsan") &&(document.forms['tt'].psd.value=="123")){
location.href="logok.html";
return true;
}else{
window.alert("错误");
return false;
}
}
</script>


<body>
<form id="tt" name="tt" method="post" >
<table border="0" align="center">
<tr>
<td>用户名:</td>
<td> <input name="user" type="text" id="user" />
</td>
</tr>
<tr>
<td>密码:</td>
<td> <input name="psd" type="password" id="psd" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="Submit" value="登陆" onclick="return check();" /> </td>
</tr>
</table>
<table border="0" align="center">
</form>
</body>
</html>



OK的没问题啊
ljm19891118 2009-12-25
  • 打赏
  • 举报
回复
把表单去掉
就调用了logok.html了
但是加上表单怎么改
ljm19891118 2009-12-25
  • 打赏
  • 举报
回复
按照楼上的试了下
输入正确的帐号密码
还是没反映


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登陆</title>
</head>

<script language="javascript">
function check(){
if((document.forms['tt'].user.value=="zhangsan") &&(document.forms['tt'].psd.value=="123")){
location.href="logok.html";
return true;
}else{
window.alert("错误");
return false;
}
}
</script>


<body>
<form id="tt" name="tt" method="post" >
<table border="0" align="center">
<tr>
<td>用户名:</td>
<td> <input name="user" type="text" id="user" />
</td>
</tr>
<tr>
<td>密码:</td>
<td> <input name="psd" type="password" id="psd" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="Submit" value="登陆" onclick="return check();" /> </td>
</tr>
</table>
<table border="0" align="center">
</form>
</body>
</html>

街头小贩 2009-12-25
  • 打赏
  • 举报
回复

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登陆</title>
</head>

<script language="javascript">
function check(){
if((document.forms['tt'].user.value=="zhangsan") &&(documeng.forms['tt'].psd.value=="123")){
location.href="logok.html";
return true;
}else{
window.alert("错误");
return false;
}
}
</script>


<body>
<form id="tt" name="tt" method="post" >
<table border="0" align="center">
<tr>
<td>用户名:</td>
<td> <input name="user" type="text" id="user" />
</td>
</tr>
<tr>
<td>密码:</td>
<td> <input name="psd" type="password" id="psd" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="Submit" value="登陆" onclick="return check();" /> </td>
</tr>
</table>
<table border="0" align="center">
</form>
</body>
</html>


61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧