蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

[ asp]请各位高手帮忙看一下这两段代码!


当提交1.asp时, 总是出现    {alert("输入数据、同义词和反义词中只少有一项为空,请填写完整。")  }   的对话框,就算添入数据也一样。
大家给指点一二!这里先谢过!




1.asp
-----------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<title>添加数据</title>
</head>
<body>
<form action="2.asp" method="post" enctype="multipart/form-data" name="form1">
  <table width="94%"  border="0" cellpadding="0" cellspacing="0" bordercolor="#3366FF">
    <tr>
      <th width="32%" scope="row"><div align="right">输入:</div></th>
      <th width="34%" height="36" scope="row"><div align="left">
        <input name="aa" type="text" size="30">
       </div></th>
      <th width="34%" scope="row"><div align="left">    相似词</div></th>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <th height="33" scope="row">              </th>
      <th height="33" scope="row">(无具体数据时点击)</th>
    </tr>
    <tr>
      <th scope="row"><div align="right">同义词:</div></th>
      <th height="33" colspan="2" scope="row"><div align="left">
        <input name="bb" type="text" size="30">
      </div></th>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <th height="33" colspan="2" scope="row">&nbsp;</th>
    </tr>
    <tr>
      <th scope="row"><div align="right">反义词:</div></th>
      <th height="35" colspan="2" scope="row"><div align="left">
        <input name="cc" type="text" size="30">
      </div></th>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <th height="34" colspan="2" bordercolor="#333333" scope="row">&nbsp;</th>
    </tr>
    <tr>
      <th scope="row"> <div align="right">英文: </div></th>
      <th height="31" colspan="2" scope="row"><div align="left">
    <input name="dd" type="text" size="30">
      </div></th>
    </tr>
        <tr>
  <td height="39" align="right">&nbsp;</td>
  <td colspan="2">&nbsp;</td>
        </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <th height="35" colspan="2" scope="row">&nbsp;</th>
    </tr>
    <tr>
      <th scope="row"><div align="right">句子举例:</div></th>
      <th height="36" colspan="2" scope="row"><div align="left">
        <input name="ee" type="text" size="30">
      </div></th>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <th height="32" colspan="2" scope="row">&nbsp;</th>
    </tr>
    <tr>
      <th scope="row"><div align="right">English Translation:</div></th>
      <th height="32" colspan="2" scope="row"><div align="left">
        <input name="ff" type="text" size="30">
</div></th>
    </tr>
    <tr>
      <th scope="row"><div align="center">
         </div></th>
      <th height="30" colspan="2" bordercolor="#0033CC" scope="row"><div align="left">
             
<input type="submit" name="Submit" value="提交">         
<input type="reset" name="Submit2" value="重写">  
</div></th>
    </tr>
  </table>
</form>
</body>
</html>
------------------------------------------------------------------
2.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<title>保存添加数据页面</title>
</head>

<body>
<!-- #include virtual ="./adovbs.inc" -->

<%
aa=Request.Form("aa")
bb=Request.Form("bb")
cc=Request.Form("cc")
dd=Request.Form("dd")
ee=Request.Form("ee")
ff=Request.Form("ff")

if aa="" or bb="" or cc="" then
%>
<script language="vbscript">
alert("输入数据、同义词和反义词中只少有一项为空,请填写完整。")
history.back
</script>
<%
else
dim cnn,rst
set cnn=server.CreateObject("adodb.connection")
cnn.ConnectionString="PROVIDER=Microsoft.jet.OLEDB.4.0;Data Source=" & server.MapPath("./mianshi.mdb")
cnn.open
set rst=server.CreateObject("adodb.recordset")
set rst1=server.CreateObject("adodb.recordset")
ssql="select * from 数据表 where 输入数据='"&aa&"'"
rst.open ssql,cnn1,1,1
if rst.eof or rst.bof then
rst1.open "数据表",cnn, 1,2
rst1.addnew array("输入数据","同义词","反义词","英文","句子举例","English Translation"),array(aa,bb,cc,dd,ee,ff)
rst1.update
%>
<script language="vbscript">
alert("数据添加成功!")
window.location.href="background.asp"
</script>
<%
rst1.close
set rst1=nothing
else
%>
<script language="vbscript">
alert("数据名为:“<%=aa %>” 的记录已经存在。")
history.back
</script>
<%
end if
rst.close
set rst=nothing
end if
%>
<h3>记录添加成功!</h3>
<p><a href="add.htm">返回记录添加表单</a> || <a href="index.asp">返回首页</a>

</body>
</html>
------------------


<form action="2.asp" method="post" enctype="multipart/form-data" name="form1">
中的
enctype="multipart/form-data"去掉试试看




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com