脚本就放在表单所在的页面啊.下面是整个页面的代码:
-----------------------------------------------------------------------------------<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conn.asp" -->
<!--#include file="chklogin.asp"--><%
Dim Rs_mycomm
Dim Rs_mycomm_numRowsSet Rs_mycomm = Server.CreateObject("ADODB.Recordset")
Rs_mycomm.ActiveConnection = MM_conn_STRING
Rs_mycomm.Source = "SELECT * FROM dbo.用户表"
Rs_mycomm.CursorType = 0
Rs_mycomm.CursorLocation = 2
Rs_mycomm.LockType = 1
Rs_mycomm.Open()Rs_mycomm_numRows = 0
%><HTML>
<HEAD>
<TITLE></TITLE>
<meta http-equiv="Content-Language" content="zh-cn">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="frame.css" type=text/css rel=stylesheet>
<style type="text/css">
<!--
-->
</style>
</HEAD><BODY leftMargin=0 background=images/bg.gif topMargin=0 marginheight="0" marginwidth="0"><TABLE align="center" cellSpacing=0 cellPadding=0 width=759 border=0>
<TBODY>
<TR>
<TD vAlign=top width=3 background=images/bg6.gif bgColor=#56768C><IMG src="images/bg6.gif" width="3" height="3"></TD>
<TD vAlign=top width=753 bgColor=#94A4BC >
<TABLE cellSpacing=0 cellPadding=0 width=753 border=0>
<TBODY>
<TR><TD valign="top" width=753 bgColor=#94A4BC>
<TABLE cellSpacing=0 cellPadding=0 width=753 border=0>
<TBODY>
<TR vAlign=bottom>
<TD width="520"></TD>
<TD height=16 width="230" bgcolor="#94A4BC" id="clock" align="right">
</TD>
</TR>
<TR vAlign=top>
<TD height=17 colspan="2"><IMG src="images/topsplite.gif" width="753" height="17"></TD>
</TR>
</TBODY>
</TABLE></TD></TR>
<TR><TD>
<TABLE cellSpacing=0 cellPadding=0 width=753 border=0 bgcolor=#94A4BC>
<TBODY>
<TR>
<TD vAlign=top height=200>
<!--中间内容开始-->
<DIV align="center">
<script>
//不同函数实现提交表单的不同操作
function submitit(myform)
{
}
function saveit(myform)
{
if (confirm("是否保存所有修改?"))
{
eval(myform).action="adduser.asp";
eval(myform).submit();
}
}function delit(myform)
{
if (confirm("将删除所选员工数据数据?"))
{
eval(myform).action="userdel.asp";
eval(myform).submit();
}
}//删除和修改前的系统提示
</script>
<table border="1" cellpadding="0" cellspacing="1" style="border-collapse: collapse" bordercolor="#C0C0C0" width="99%" id="AutoNumber3" height="20">
<form name="shit" method="POST" action="adduser.asp">
<tr>
<td width="120" bgcolor="#E1E1E1">
<p align="center">添加新员工</td>
<td>
<p align="left">
<input type="text" name="newone1" size="16" onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal" value="请输入姓名">
<input type="text" name="newone2" size="16" onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal" value="请输入部门">
<input type="text" name="newone3" size="16" onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal" value="请输入班组">
<input type="text" name="newone4" size="16" onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal" value="请输入职务">
</td>
<td width="59">
<p align="center">
<input border="0" value="添 加" name="I1" type="submit" class="s02"></td>
</tr>
</form>
</table>
<p><br>
</p>
<table border="1" cellpadding="0" cellspacing="1" style="border-collapse: collapse" bordercolor="#C0C0C0" width="99%" id="AutoNumber1">
<form name="alluserdetail" method="get" onSubmit="return submitit(this)">
<tr>
<td width="30" align="center" bgcolor="#E1E1E1" height="20"> </td>
<td width="30" align="center" bgcolor="#E1E1E1"><b>序号</b></td>
<td align="left" bgcolor="#E1E1E1"> <b>姓名</b></td>
<td align="left" bgcolor="#E1E1E1"> <b>部门</b></td>
<td align="left" bgcolor="#E1E1E1"> <b>班组</b></td>
<td align="left" bgcolor="#E1E1E1"> <b>职务</b></td>
</tr>
<%
i=0
do while not rs_mycomm.eof
'显示已有的名单
%>
<tr>
<td align="center" bgcolor="#E1E1E1">
<input type="checkbox" name="id" value="<%=rs_mycomm("id")%>"></td>
<td align="center"><%=i%> </td>
<td align="left" colspan="4">
<input type="text" name="exam_subject" size="20" value="<%=rs_mycomm("姓名")%>"
onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal">
</td>
</tr>
<%
i=i+1
rs_mycomm.movenext
loop
%>
<caption>
<p align="right">
<input type="submit" value="删除所选项" name="del1" onclick="delit(alluserdetail)" class="s02">
<input type="submit" value="保 存" name="edit1" onclick="saveit(alluserdetail)" class="s02"></p>
</caption>
</form>
</table>
</DIV>
<!--中间内容结束-->
</TD>
</TR>
</TBODY>
</TABLE>
</TD></TR>
</TBODY>
</TABLE>
<TD vAlign=top width=3 background=images/bg6.gif></TD>
</TR> <TR><TD colspan="3" height="3" width="759" background="images/bg7.gif"></TD></TR>
</TBODY>
</Table></BODY>
</HTML><%
Rs_mycomm.Close()
Set Rs_mycomm = Nothing
%>
------------------------------------------------------------------------------
-----------------------------------------------------------------------------------<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conn.asp" -->
<!--#include file="chklogin.asp"--><%
Dim Rs_mycomm
Dim Rs_mycomm_numRowsSet Rs_mycomm = Server.CreateObject("ADODB.Recordset")
Rs_mycomm.ActiveConnection = MM_conn_STRING
Rs_mycomm.Source = "SELECT * FROM dbo.用户表"
Rs_mycomm.CursorType = 0
Rs_mycomm.CursorLocation = 2
Rs_mycomm.LockType = 1
Rs_mycomm.Open()Rs_mycomm_numRows = 0
%><HTML>
<HEAD>
<TITLE></TITLE>
<meta http-equiv="Content-Language" content="zh-cn">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="frame.css" type=text/css rel=stylesheet>
<style type="text/css">
<!--
-->
</style>
</HEAD><BODY leftMargin=0 background=images/bg.gif topMargin=0 marginheight="0" marginwidth="0"><TABLE align="center" cellSpacing=0 cellPadding=0 width=759 border=0>
<TBODY>
<TR>
<TD vAlign=top width=3 background=images/bg6.gif bgColor=#56768C><IMG src="images/bg6.gif" width="3" height="3"></TD>
<TD vAlign=top width=753 bgColor=#94A4BC >
<TABLE cellSpacing=0 cellPadding=0 width=753 border=0>
<TBODY>
<TR><TD valign="top" width=753 bgColor=#94A4BC>
<TABLE cellSpacing=0 cellPadding=0 width=753 border=0>
<TBODY>
<TR vAlign=bottom>
<TD width="520"></TD>
<TD height=16 width="230" bgcolor="#94A4BC" id="clock" align="right">
</TD>
</TR>
<TR vAlign=top>
<TD height=17 colspan="2"><IMG src="images/topsplite.gif" width="753" height="17"></TD>
</TR>
</TBODY>
</TABLE></TD></TR>
<TR><TD>
<TABLE cellSpacing=0 cellPadding=0 width=753 border=0 bgcolor=#94A4BC>
<TBODY>
<TR>
<TD vAlign=top height=200>
<!--中间内容开始-->
<DIV align="center">
<script>
//不同函数实现提交表单的不同操作
function submitit(myform)
{
}
function saveit(myform)
{
if (confirm("是否保存所有修改?"))
{
eval(myform).action="adduser.asp";
eval(myform).submit();
}
}function delit(myform)
{
if (confirm("将删除所选员工数据数据?"))
{
eval(myform).action="userdel.asp";
eval(myform).submit();
}
}//删除和修改前的系统提示
</script>
<table border="1" cellpadding="0" cellspacing="1" style="border-collapse: collapse" bordercolor="#C0C0C0" width="99%" id="AutoNumber3" height="20">
<form name="shit" method="POST" action="adduser.asp">
<tr>
<td width="120" bgcolor="#E1E1E1">
<p align="center">添加新员工</td>
<td>
<p align="left">
<input type="text" name="newone1" size="16" onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal" value="请输入姓名">
<input type="text" name="newone2" size="16" onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal" value="请输入部门">
<input type="text" name="newone3" size="16" onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal" value="请输入班组">
<input type="text" name="newone4" size="16" onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal" value="请输入职务">
</td>
<td width="59">
<p align="center">
<input border="0" value="添 加" name="I1" type="submit" class="s02"></td>
</tr>
</form>
</table>
<p><br>
</p>
<table border="1" cellpadding="0" cellspacing="1" style="border-collapse: collapse" bordercolor="#C0C0C0" width="99%" id="AutoNumber1">
<form name="alluserdetail" method="get" onSubmit="return submitit(this)">
<tr>
<td width="30" align="center" bgcolor="#E1E1E1" height="20"> </td>
<td width="30" align="center" bgcolor="#E1E1E1"><b>序号</b></td>
<td align="left" bgcolor="#E1E1E1"> <b>姓名</b></td>
<td align="left" bgcolor="#E1E1E1"> <b>部门</b></td>
<td align="left" bgcolor="#E1E1E1"> <b>班组</b></td>
<td align="left" bgcolor="#E1E1E1"> <b>职务</b></td>
</tr>
<%
i=0
do while not rs_mycomm.eof
'显示已有的名单
%>
<tr>
<td align="center" bgcolor="#E1E1E1">
<input type="checkbox" name="id" value="<%=rs_mycomm("id")%>"></td>
<td align="center"><%=i%> </td>
<td align="left" colspan="4">
<input type="text" name="exam_subject" size="20" value="<%=rs_mycomm("姓名")%>"
onblur="this.className='inputnormal'" onfocus="this.className='inputedit';this.select()" class="inputnormal">
</td>
</tr>
<%
i=i+1
rs_mycomm.movenext
loop
%>
<caption>
<p align="right">
<input type="submit" value="删除所选项" name="del1" onclick="delit(alluserdetail)" class="s02">
<input type="submit" value="保 存" name="edit1" onclick="saveit(alluserdetail)" class="s02"></p>
</caption>
</form>
</table>
</DIV>
<!--中间内容结束-->
</TD>
</TR>
</TBODY>
</TABLE>
</TD></TR>
</TBODY>
</TABLE>
<TD vAlign=top width=3 background=images/bg6.gif></TD>
</TR> <TR><TD colspan="3" height="3" width="759" background="images/bg7.gif"></TD></TR>
</TBODY>
</Table></BODY>
</HTML><%
Rs_mycomm.Close()
Set Rs_mycomm = Nothing
%>
------------------------------------------------------------------------------
function saveit(myform)
{
if (confirm("是否保存所有修改?"))
{
myform.action="adduser.asp"; //用不着加 eval
myform.submit();
}
}function delit(myform)
{
if (confirm("将删除所选员工数据数据?"))
{
myform.action="userdel.asp";
myform.submit();
}
}//删除和修改前的系统提示<input type="submit" value="删除所选项" onclick="delit(this.form)">
<input type="submit" value="保 存" onclick="saveit(this.form)">
可以直接用 this.form 调用按钮所在的表单
原因出在form的method不是post而是get
改成post就可以了.非常感谢你的热心帮助碰巧改成功了,不知道原因.
能不能帮我解释一下为什么改成post就可以了,post跟get有什么区别?
eval是干什么用的?还有为什么要用this.form不直接用form的名字?
初学,问题多了一点 :)
eval() 是强制将一个字符串转换成JS语句来执行
用 this.form 当然比用formName好, 一个是不会出错, 二是程序更具有扩展性