这是代码
<!--#include file="..\Data\Data_connect.asp"-->
<SCRIPT language=javascript>
function form1_onsubmit()
{
if(document.FORM1.department.value.length<1)
{
alert("请填写正确的部门名称!");
document.FORM1.department.focus();
return false;
}
if(document.FORM1.name.value.length<1)
{
alert("请填写正确的姓名!");
document.FORM1.name.focus();
return false;
}
}
</SCRIPT>
<%
IF Request.Form("action")="添加信息" Then
department=trim(request("department"))
name=trim(request("name"))
jiaoxue=trim(request("jiaoxue"))
jiaoxue_total=trim(request("jiaoxue_total"))
xueke_total=trim(request("xueke_total"))
xueke=trim(request("xueke"))
total=trim(request("total"))
set rsZZ=server.createobject("adodb.recordset")
sqltext="select * from [jiaoxuejiang] where department='"&department&"'"
rsZZ.open sqltext,conn,3,3
if rsZZ.recordcount>0 then
response.write "<script language=JavaScript>{window.alert('此信息已经添加,请添加其他信息!');}</script>"
else
'添加一条记录到数据库
rsZZ.addnew
rsZZ("department")=department
rsZZ("name")=name
rsZZ("jiaoxue")=jiaoxue
rsZZ("jiaoxue_total")=jiaoxue_total
rsZZ("xueke_total")=xueke_total
rsZZ("xueke")=xueke
rsZZ("total")=total
sqltext="select jiaoxue_total,xueke_total , total from jiaoxuejiang
"
union
sqltext="select sum(total) as total,sum(jiaoxue_total) as jiaoxue_total,sum(xueke_total) as xueke_total from jiaoxuejiang"
rsZZ.update
rsZZ.close
response.write "<script language=JavaScript>{window.alert('此部门添加成功!');opener.parent.main.location.href='../jiaoxuejiang/jiaoxuejiang.asp';window.close();}</script>"
response.end
end if
End If
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../Css/Styles.css">
<title>信息添加</title>
</head>
<body oncontextmenu=self.event.returnValue=false>
<div align="left">
<form method="POST" action="../jiaoxuejiang/add.asp" name=FORM1 onSubmit="return form1_onsubmit()">
<table border="1" cellpadding="0" width="100%" bordercolorlight="#A8CBF1" bordercolordark="#FFFFFF" cellspacing="0" height="66">
<tr>
<td colspan="12" bgcolor="#A8CBF1" height="22"><b>信息添加</b></td>
</tr>
<tr>
<td width="6%" height="40" bgcolor="#E9F4FF" align="left">
<div align="center">部门名称:</div></td>
<td width="7%" height="40" bgcolor="#E9F4FF">
<input name="department" type="text" id="department" size="8"></td>
<td width="3%" bgcolor="#E9F4FF"><div align="center">姓名:</div></td>
<td width="7%" bgcolor="#E9F4FF"><input name="name" type="text" id="name" size="8"></td>
<td width="4%" bgcolor="#E9F4FF"><div align="center">教学:</div></td>
<td width="24%" bgcolor="#E9F4FF"><select name="jiaoxue" id="jiaoxue">
<option value="无">无</option>
<option value="国家级教学名师">国家级教学名师</option>
<option value="省部级教学名师">省部级教学名师</option>
<option value="校级教学名师">校级教学名师</option>
<option value="综合评教">综合评教</option>
<option value="天津市青年教师基本功一等奖">天津市青年教师基本功一等奖</option>
<option value="天津市青年教师基本功二等奖">天津市青年教师基本功二等奖</option>
<option value="天津市青年教师基本功三等奖">天津市青年教师基本功三等奖</option>
</select></td>
<td width="6%" bgcolor="#E9F4FF"><div align="right">
<input name="jiaoxue_total" type="text" id="jiaoxue_total" size="4">
分</div></td>
<td width="6%" bgcolor="#E9F4FF"><div align="center">学科:</div></td>
<td width="15%" bgcolor="#E9F4FF"><select name="xueke" id="xueke">
<option value="无">无</option>
<option value="国家级一等奖">国家级一等奖</option>
<option value="国家级二等奖">国家级二等奖</option>
<option value="国家级三等奖">国家级三等奖</option>
<option value="省部级一等奖">省部级一等奖</option>
<option value="省部级二等奖">省部级二等奖</option>
<option value="省部级三等奖">省部级三等奖</option>
<option value="专业团体一等奖">专业团体一等奖</option>
<option value="专业团体二等奖">专业团体二等奖</option>
<option value="专业团体三等奖">专业团体三等奖</option>
</select></td>
<td width="6%" bgcolor="#E9F4FF"><div align="right">
<input name="xueke_total" type="text" id="xueke_total"
size="4">
分 </div></td>
<td width="8%" bgcolor="#E9F4FF"><div align="center">总分数:</div></td>
<td width="8%" bgcolor="#E9F4FF"><input name="total" type="text" id="total" size="8"></td>
</tr>
<tr>
<td height="40" bgcolor="#E9F4FF" colspan="12" align="parent">
<p align="center"><input class=button1 type="submit" value="添加信息" name="action">
<INPUT class=button1 onclick=javascript:window.close() type=button value=关闭></p>
</td>
</tr>
</table>
</form>
</div>
<p align="parent"> </p>
</body>
</html>