表单提交在本页面操作的问题
一个页面提交表单到另一个页面的问题,我想要表单提交动作在本页面执行,比如页面a提交表单到页面b,a
程序代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www."> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head> <body> <script language="javascript1.1" > function checkform(){ if(document.forma.tm.value==''){ alert('请填写题目!!'); document.forma.tm.focus(); return false; } if(document.forma.a.value==''){ alert('请填写答案A!!'); document.forma.a.focus(); return false; } if(document.forma.b.value==''){ alert('请填写答案B!!'); document.forma.b.focus(); return false; } if(document.forma.c.value==''){ alert('请填写答案C!!'); document.forma.c.focus(); return false; } if(document.forma.d.value==''){ alert('请填写答案D!!'); document.forma.d.focus(); return false; } if(document.forma.an.value=='请选择'){ alert('请填选择答案!!'); document.forma.an.focus(); return false; } return true; } </script> <table width="781" border="1" align="center" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="781" height="73" align="left">这是题目</td> </tr> </table> <table width="781" height="501" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <!--DWLayoutTable--> <tr> <td width="781" height="364"> <form action="insert.asp" method="post" name="forma" id="forma" onSubmit="return checkform()"> <table width="761" height="273" border="1" cellspacing="0"> <tr> <td width="48" height="30" align="center" valign="middle">考题</td> <td width="709" bgcolor="#FFFFFF"><textarea name="tm" cols="80" rows="3" id="tm"></textarea></td> </tr> <tr> <td height="30" align="center" valign="middle">A</td> <td bgcolor="#FFFFFF"><input name="a" type="text" id="a" size="80"></td> </tr> <tr> <td height="30" align="center" valign="middle">B</td> <td bgcolor="#FFFFFF"><input name="b" type="text" id="b" size="80"></td> </tr> <tr> <td height="30" align="center" valign="middle">C</td> <td bgcolor="#FFFFFF"><input name="c" type="text" id="c" size="80"></td> </tr> <tr> <td height="30" align="center" valign="middle">D</td> <td bgcolor="#FFFFFF"><input name="d" type="text" id="d" size="80"></td> </tr> <tr> <td height="49" rowspan="2" align="center" valign="top"><p> </p> <p>正确</p></td> <td bgcolor="#FFFFFF"><select name="an" id="an"> <option value="请选择" selected>请选择</option> <option value="A">A</option> <option value="B">B</option> <option value="C">C</option> <option value="D">D</option> </select></td> </tr> <tr> <td bgcolor="#FFFFFF"><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"> <a href="list.asp">查看考题</a></td> </tr> </table> </form> </td> </tr> <tr> </tr> </table> <table width="781" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="781" height="114"> </td> </tr> </table> </body> </html>
b
程序代码:
<!--#include file="conn.asp"--> <% set rs= Server.CreateObject("adodb.recordset") sql ="select * from db" rs.open sql,conn,1,3 rs.addnew rs("tm")=request("tm") rs("a")=request("a") rs("c")=request("c") rs("d")=request("d") rs("an")=request("an") rs.update Response.Write "<script>alert('添加成功,请继续添加');this.location.href='index.asp';</script>" set conn=nothing %>想要的最佳结果就是将页面b的代码放到b里,我试过,会出现先执行b里的代码,就是反复弹出提示,请各位给指导下,谢谢