为什么不能页面跳转!!!!!!!!!!!!!!!

freedom1980 2004-08-26 04:31:23


<html>
<head>
<script language=JavaScript>
function checkform() {
var flag=true;
var str=document.form1.customer.value;
var psw=document.form1.psw.value;
if(str==""||str==null){
alert("name can't be empty!idot!");
}
else if(str!="lgj")
alert("name is wrong");
else if(psw!="123")
alert("pass word is wrong");
document.form1.action="information.jsp";
document.form1.submit();

}
</script>
</head>
<body >
<form name=form1 >
<p align=center>country<select name=cuntry >
<option value=china >china</option>
<option value=usa>usa</option>
<option value=austrilia>austrilia<option>
</select>
<p align=center>username<input type=text name="customer" maxlength=10 size=10>

<p align=center>password<input type=password name="psw" maxlength=10 size=10 >

<p align=center><input type=button name=submit value="subsmit" onClick="checkf
orm()">
<input type=reset name=reset value="reset">
</form>
</body>
</html>

错误提示: document.form1.submit();对象不支持这个属性或方法错误

...全文
134 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
newcomer2004 2004-08-28
  • 打赏
  • 举报
回复
要用input type=submit 标明要提交,同时checkform() 要有返回值。
至于学习资料,网上很多,javascript宝典还是不错的。
CHLC 2004-08-26
  • 打赏
  • 举报
回复
Sorry!
vitamines 2004-08-26
  • 打赏
  • 举报
回复
因为你原来没有触发提交的事件
freedom1980 2004-08-26
  • 打赏
  • 举报
回复
对了
能不能告诉我为什么这样改啊
freedom1980 2004-08-26
  • 打赏
  • 举报
回复
对了 请问还有其他的方法来提交页面
常用的
最好能不能介绍些电子资料
谢谢
freedom1980 2004-08-26
  • 打赏
  • 举报
回复
谢谢啊
newcomer2004 2004-08-26
  • 打赏
  • 举报
回复
提交的方法有问题,修改如下,加 //// 的地方是要注意的。测试过可用的
<html>
<head>
<script language=JavaScript>
function checkform() {
var flag=true;
var str=document.form1.customer.value;
var psw=document.form1.psw.value;
if(str==""||str==null){
alert("name can't be empty!idot!");
return false; ////
}
else if(str!="lgj")
{ alert("name is wrong"); return false; } ////
else if(psw!="123")
{ alert("pass word is wrong"); return false; } ////
document.form1.action="information.jsp";
document.form1.submit();
return true;
}
</script>
</head>
<body >
<form name=form1 >
<p align=center>country<select name=cuntry >
<option value=china >china</option>
<option value=usa>usa</option>
<option value=austrilia>austrilia<option>
</select>
<p align=center>username<input type=text name="customer" maxlength=10 size=10>

<p align=center>password<input type=password name="psw" maxlength=10 size=10 >

<p align=center><input type=submit name=submit value="subsmit" onClick="checkform()"> ////提交方法不对
<input type=reset name=reset value="reset">
</form>
</body>
</html>

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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