<script language="javascript">
function btnClick()
{
document.form1.action = "./处理1.asp";
document.form1.submit();
document.form1.action = "./处理2.asp";
document.form1.submit();
}
</script><body>
<form name="form1">
<input type="button" name="btn" value="提交" onClick="btnClick()">
</form>
</body>有一个提交按钮,点击后执行javascript程序btnClick(),先提交执行处理1.asp,再提交执行处理2.asp。
请问,btnClick中的执行顺序是先执行完处理1.asp后才执行处理2.asp的吗?即不执行完处理1.asp是不会继续执行处理2.asp程序,是这样吗?
function btnClick()
{
document.form1.action = "./处理1.asp";
document.form1.submit();
document.form1.action = "./处理2.asp";
document.form1.submit();
}
</script><body>
<form name="form1">
<input type="button" name="btn" value="提交" onClick="btnClick()">
</form>
</body>有一个提交按钮,点击后执行javascript程序btnClick(),先提交执行处理1.asp,再提交执行处理2.asp。
请问,btnClick中的执行顺序是先执行完处理1.asp后才执行处理2.asp的吗?即不执行完处理1.asp是不会继续执行处理2.asp程序,是这样吗?
提交后后面的代码不会执行的
为什么两个处理界面不放在一起呢? 您的意思是说将处理1.asp和处理2.asp的内容合并成一个文件???
<!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 btnClick()
{
document.form1.action = "./处理1.asp";
document.form1.submit();
document.form1.action = "./处理2.asp";
document.form1.submit();
}
</script>
<body>
<form name="form1" method="post" action="">
<input type="button" name="btn" value="提交" onClick="btnClick()">
</form>
</body>
</html>
处理1.asp文件内容如下:
<!-- #include file="./ins/Connect.asp" -->
<!-- #include file="./ins/function.asp" -->
<!-- #include file="./ins/topCode.asp" -->
<!-- #include file="./ins/adovbs.inc"-->
<!-- #include file="./ins/checklogin.asp" --><!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>
<body>
<%
dim counts sql = "delete from hh where userid='888888'"
conn.Execute sql,counts,adCmdText
sql = "insert into hh values('888888')"
conn.Execute sql,counts,adCmdText
conn.close
set conn = nothing
%>
</body>
</html>
处理2.asp文件内容如下:
<!-- #include file="./ins/Connect.asp" -->
<!-- #include file="./ins/function.asp" -->
<!-- #include file="./ins/topCode.asp" -->
<!-- #include file="./ins/adovbs.inc"-->
<!-- #include file="./ins/checklogin.asp" --><!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>
<body>
<%
dim counts sql = "delete from hh where userid='999999'"
conn.Execute sql,counts,adCmdText
sql = "insert into hh values('999999')"
conn.Execute sql,counts,adCmdText
conn.close
set conn = nothing
%>
</body>
</html>
点击提交按钮后,查询数据库表hh确实有888888和999999的记录。
document.form1.action = "./处理1.asp";
document.form1.submit();
之后理论上应该是跳转到1.asp并执行
但因为之前有一个提交的过程又因为网络的关系并不一定立即就能跳转到但submit的工作实际上已经完成了就是这个不能立即跳转的时间就执行了下面的程序
document.form1.action = "./处理2.asp";
document.form1.submit(); 同样的执行过程
但这只是我的理解谁有比较专业的解释