<!-- #include file="conn.asp" -->
<body bgcolor="">
<SCRIPT LANGUAGE="vbScript">
Sub insert()
If f1.t1.value="" Then
msgbox"图书名不能为空!"
else
f1.action="as_insert_book.asp?q=1"
f1.submit
end if
End Sub
</SCRIPT>
<FORM METHOD=POST ACTION="" name="f1">
<TABLE border="1" align="center">
<TR>
<TD height="50"><CENTER>添加图书</CENTER></TD>
</TR>
<TR>
<TD height="40">图书名:<INPUT TYPE="text" NAME="t1"> <FONT COLOR="red">*</FONT></TD>
</TR>
<TR>
<TD height="40">作 者:<INPUT TYPE="text" NAME="t2"></TD>
</TR>
<TR>
<TD height="40">出版社:<INPUT TYPE="text" NAME="t3"></TD>
</TR>
<TR>
<TD height="40">类 别:
<SELECT NAME="t4">
<OPTION VALUE="文学艺术类">文学艺术类
<OPTION VALUE="计算机类">计算机类
<OPTION VALUE="社会科学类">社会科学类
<OPTION VALUE="自然科学类">自然科学类
<OPTION VALUE="外文书籍类">外文书籍类
<OPTION VALUE="其他">其他
</SELECT>
</TD>
</TR>
<TR height="40">
<TD>价 格:<INPUT TYPE="text" NAME="t5">元</TD>
</TR>
<TR height="40">
<TD><CENTER><INPUT TYPE="submit" value=" 添加 " onclick="insert()"> <INPUT TYPE="reset" value=" 取消 "></CENTER></TD>
</TR>
<TR>
<TD><FONT SIZE="4" COLOR="red"><CENTER>*为必填内容</CENTER></FONT></TD>
</TR>
</TABLE>
<%
If request("q")="1" Then
conn.execute("insert into book(Book_Name,Book_Author,Book_Press,Book_Category,Book_Price) values('" & request("t1") & "','" & request("t2") & "','" & request("t3") & "','" & request("t4") & "','" & request("t5") & "')")
'成功后跳转
response.write"<SCRIPT LANGUAGE='JavaScript'>"
response.write"alert('你已经成功添加一本图书!');"
response.write "location.href='see_book.asp'"
response.write"</SCRIPT>"
End If
%>
</FORM>
</body>
就这个代码 他执行2遍插入语句