回 帖 发 新 帖 刷新版面

主题:求把搜索和显示的分开!asp+access

共分三个页面,一个主页表单提交“书名.作者、出版社”等条件查询!代码如下:最好辅助说明!<!--#include file="conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/config.asp"-->
<HTML>
<HEAD><script type="text/javascript">function DDtoDay(inputDate)

{

  var dateString = new Array('','st','nd','rd','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','th','st','nd','rd','th','th','th','th','th','th','th','st');

  returnDate = '';

  tempDate = parseInt(inputDate);

  if (tempDate >= 1 && tempDate <= 31)

  {

          returnDate = inputDate + dateString[tempDate];

        }

        return returnDate;

}</script>
<TITLE><%=fypSysTitle & " " & currentAspFileName()%></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<LINK HREF="css/css.css" REL="stylesheet" TYPE="text/css">
<SCRIPT LANGUAGE="javascript" SRC="js/js.js"></SCRIPT>
<style type="text/css">
<!--
#apDiv1 {
        position:absolute;
        left:25px;
        top:96px;
        width:423px;
        height:55px;
        z-index:1;
}
#apDiv2 {
        position:absolute;
        left:122px;
        top:266px;
        width:860px;
        height:133px;
        z-index:2;
}
-->
</style>
</head>
<script type="text/javascript" src="flashfloat.js"></script>
<script type="text/javascript" src="flashobject.js"></script>
<BODY LEFTMARGIN="0" TOPMARGIN="0">
<FORM ACTION="<%=currentAspFileFullName()%>" METHOD="post" NAME="<%=currentAspFileName()%>_Form" ID="<%=currentAspFileName()%>_Form" STYLE="display:inline"  onsubmit="return checkForm(this)">
  <div id="apDiv1">
    <div id="macro-style_id" >daohang</div>
    <script type="text/javascript">
   var fo = new FlashObject("jw1.swf", "macro-style", "400", "65", "6", "#FFFFFF");
    fo.addParam("menu","false");
    fo.addParam("quality","best");
    fo.addParam("salign","LT");
    fo.addParam("scale","noscale");
    fo.addParam("wmode","transparent");
    fo.write("macro-style_id");
if (navigator.appName.indexOf("Microsoft")!= -1) {
document.floater.style.position="absolute";
document.floater.style.zIndex="10";
document.floater.style.left="0px";
document.floater.style.top="0px";
}else{
document.getElementById('floater').style.position="absolute";
document.getElementById('floater').style.zIndex="10";
document.getElementById('floater').style.left="0px";
document.getElementById('floater').style.top="0px";
}</script>
  </div>
  <p><img src="images/index.jpg" width="950" height="195"></p>
  <TABLE WIDTH="" BORDER="0" ALIGN="left" CELLPADDING="5" CELLSPACING="1" CLASS="tableStyleSolidLine">
    <tr>
      <td width="39" nowrap>[书名]</td>
      <td width="0"></td>
      <td width="153"><input type='text' name='ctrl_ShuMing' id='ctrl_ShuMing' maxlength='255' value='<%=Request.Form("ctrl_ShuMing")%>' style='width:100%' class='textBox'></td>
      <td width="33">[作者]</td>
      <td width="190"><input type='text' name='ctrl_ZuoZhe' id='ctrl_ZuoZhe' maxlength='255' value='<%=Request.Form("ctrl_ZuoZhe")%>' style='width:100%' class='textBox'></td>
      <td width="51">[出版社]</td>
      <td width="156"><input type='text' name='ctrl_ChuBanShe' id='ctrl_ChuBanShe' maxlength='255' value='<%=Request.Form("ctrl_ChuBanShe")%>' style='width:100%' class='textBox'></td>
      <td width="121"><INPUT TYPE="submit" NAME="Submit" VALUE="查找">
        <INPUT TYPE="reset" NAME="Reset" VALUE="重置"></td>
    </tr>
  </TABLE>
  <p>&nbsp;</p>
<p>&nbsp;  </p>
<p>&nbsp;  </p>
<p>
  <%
    Dim errMessage
    errMessage=""

    Dim var_ShuMing
    var_ShuMing = Request.Form("ctrl_ShuMing")

    Dim var_ZuoZhe
    var_ZuoZhe = Request.Form("ctrl_ZuoZhe")

    Dim var_ChuBanShe
    var_ChuBanShe = Request.Form("ctrl_ChuBanShe")

    If (errMessage <> "") Then
        Call Javascript("showMsg('"&replace(errMessage,"<br>","\n\n")&"'); goUrl('-1','')")
        Response.End()
    End If

Dim sql,Rs
Dim maxPerPage
Dim totalRecord
Dim currentPage
Dim totalPages
Dim strOrderBy
Dim sqlOrderByStr
Dim sqlSearch

currentPage=1
totalRecord=0
totalPages=1

maxPerPage=20
If Request.Form("maxPerPage") <> "" And isNumeric(Request.Form("maxPerPage")) Then 
    If Request.Form("maxPerPage") >= 1 Then maxPerPage=CInt(Request.Form("maxPerPage"))
    If Request.Form("maxPerPage") > 40 Then maxPerPage=40
End If

    If Request.Form("recordID") <> "" And Request.Form("actMod")="DEL" Then
    sql = "delete from [tushu] where [ID] = " & Request.Form("recordID")
        conn.execute (sql)
        Call Javascript("showMsg('成功删除本条记录'); goUrl('" & currentAspFileFullName() & "','')")
    End If



sqlSearch=""
If var_ShuMing <> "" Then sqlSearch = sqlSearch & " And [书名] like '%"& var_ShuMing &"%'"
If var_ZuoZhe <> "" Then sqlSearch = sqlSearch & " And [作者] like '%"& var_ZuoZhe &"%'"
If var_ChuBanShe <> "" Then sqlSearch = sqlSearch & " And [出版社] like '%"& var_ChuBanShe &"%'"

If sqlSearch <> "" Then
    sqlSearch="where " & mid(sqlSearch,5)
End If


sql = "select [ID], [书名], [作者], [出版社] from [tushu] " & sqlSearch & strOrderBy
Set Rs =  Server.CreateObject("ADODB.Recordset")
Rs.Open sql, conn, 1, 1

totalRecord=CInt(Rs.Recordcount)

If totalRecord>0 Then
    If Not IsEmpty(Request.Form("page")) And IsNumeric(Request.Form("page")) Then
        If Request.Form("page") >= 1 Then currentPage=CInt(Request.Form("page"))
    End If
    If Not IsEmpty(Request.QueryString("page")) And IsNumeric(Request.QueryString("page")) Then
        If Request.QueryString("page") >= 1 Then currentPage=CInt(Request.QueryString("page"))
    End If

    totalPages = CInt(totalRecord \ maxPerPage)
    If (totalRecord Mod maxPerPage) <> 0 Then totalPages = (totalRecord \ maxPerPage) + 1
    If currentPage > totalPages Then currentPage = totalPages

    Rs.Move (currentPage-1)*maxPerPage
    Dim bookmark
    bookmark=Rs.BookMark
End If

Call showPage(currentPage,totalPages,maxPerPage,totalRecord,false)
Call showContent()
Call showPage(currentPage,totalPages,maxPerPage,totalRecord,true)
%>
  
  <%
Sub showContent()
%>
</p>
<TABLE WIDTH="100%" BORDER="1" ALIGN="CENTER" CELLPADDING="5" CELLSPACING="1" CLASS="tableStyleSolidLine">
    <TR>
      <TD COLSPAN="100" BGCOLOR="#ffffff" ALIGN="center">[学院图书查询]</TD></TR>
    <tr>
      <td bgcolor="#EEEEEE">书名</td>
      
      <td bgcolor="#EEEEEE">作者</td>
      
      <td bgcolor="#EEEEEE">出版社</td>
      <td bgcolor="#EEEEEE" nowrap>&nbsp;</td>
  </tr>
    
    
    <%
    If (totalRecord>0) Then
        Dim p
        p = 1
        Do While Not Rs.Eof
        %>
    <tr>
      <td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("书名"))%></td>
      
      <td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("作者"))%></td>
      
      <td bgcolor="#FFFFFF"><%=htmEncodeStr(Rs("出版社"))%></td>
      <td bgcolor="#FFFFFF">        <a href='tushu_detail.asp?id=<%=Rs("ID")%>' target='_blank'>查看详情</a></td>
  </tr>
    <%
        If p >= maxPerPage Then Exit Do
        Rs.MoveNext()
        p = p + 1
        Loop
    Else
        Response.Write ("<tr><td colspan=""100"" bgcolor=""#ffffff"" align=""center"">暂无任何记录!</td></tr>")
    End If
    %>
    <tr>
      <td bgcolor="#EEEEEE">书名</td>
      
      <td bgcolor="#EEEEEE">作者</td>
      
      <td bgcolor="#EEEEEE">出版社</td>
      <td bgcolor="#EEEEEE" nowrap>&nbsp;</td>
  </tr>
    
  </TABLE>
  <%
End Sub
%>
  
  
  
  <SCRIPT LANGUAGE="javascript">
function goPage(strPage)
{
    document.all.page.value=strPage;
    document.<%=currentAspFileName()%>_Form.submit();
    return false;
}
function delRec(strID)
{
    if (confirm('确定删除吗?'))
    {
        document.all.recordID.value=strID;
        document.all.actMod.value='DEL';
        document.all.<%=currentAspFileName()%>_Form.submit();
    }
    else
    {
        alert('您取消了删除操作');
    }
    return false;
}

回复列表 (共2个回复)

沙发

这些事其余的代码:
</SCRIPT>
  
  <INPUT NAME="page" TYPE="hidden" VALUE="<%=currentPage%>">
  <INPUT NAME="maxPerPage" TYPE="hidden" VALUE="<%=maxPerPage%>">
  <input name="actMod" type="hidden" value="">
  <input name="recordID" id="recordID" type="hidden" value="">
  
</FORM>

<script language="javascript">
<!--
try
{

}
catch(e)
{ alert("控件不具备相应属性,请修改如下代码:\r\n" + e.description) }
function checkForm(theCheckForm)
{
    var errMessage ="";
    try
    {

    }
    catch(e)
    { alert("控件不具备相应属性,请修改如下代码:\r\n" + e.description) }
    if (errMessage !="")
    {
        alert(errMessage);
        theCheckForm.method="";
        return false;
    }

    theCheckForm.method="post";
    return true;
}
-->
</script>


<%
Rs.Close()
Set Rs = Nothing
connClose()

CheckError()
%>
</BODY>

</HTML>
、///////////////////////////////////////////////////////////////////////////
这个事静态表单页面代码:
        <img src="images/分隔符.gif" width="1" height="12" alt=""></td>
    </tr>
    <tr>
        <td colspan="2">
            <img src="images/sreach-ts_09.gif" width="134" height="161" alt=""></td>
        <td rowspan="2" background="images/sreach-ts_10.gif"><TABLE WIDTH="" BORDER="0" ALIGN="center" CELLPADDING="5" CELLSPACING="1" CLASS="tableStyleSolidLine">
          <tr>
          <form id="form1" name="form1" method="post" action="tushu_search.asp">
            <td nowrap><div align="right" class="STYLE1">[书名]</div></td>
            <td width="10"></td>
            <td width="90%"><div align="left">
              <input name='ctrl_ShuMing' type='text' class='textBox ' id='ctrl_ShuMing' style='width:100%' value='输入书名 例如“asp.net手册”' maxlength='255'>
            </div></td>
          </tr>
          <tr>
            <td nowrap><div align="right" class="STYLE1">[作者]</div></td>
            <td width="10"></td>
            <td width="90%"><div align="left">
              <input name='ctrl_ZuoZhe' type='text' class='textBox ' id='ctrl_ZuoZhe' style='width:100%' value='输入书作者 例如 “朱自清”' maxlength='255'>
            </div></td>
          </tr>
          <tr>
            <td nowrap><div align="right" class="STYLE1">[出版社]</div></td>
            <td width="10"></td>
            <td width="90%"><div align="left">
              <input name='ctrl_ChuBanShe' type='text' class='textBox ' id='ctrl_ChuBanShe' style='width:100%' value='输入书出版社 例如“人民出版社”' maxlength='255'>
            </div></td>
          </tr>
          <TR>
            <TD></TD>
            <TD WIDTH="10"></TD>
            <TD><div align="center">
              <INPUT TYPE="submit" NAME="Submit2" VALUE="查找">
              <INPUT TYPE="reset" NAME="Reset2" VALUE="重置">            
            </div></TD>
          </TR>
        </TABLE></td>
        <p>
  <%
    Dim errMessage
    errMessage=""

    Dim var_ShuMing
    var_ShuMing = Request.Form("ctrl_ShuMing")

    Dim var_ZuoZhe
    var_ZuoZhe = Request.Form("ctrl_ZuoZhe")

    Dim var_ChuBanShe
    var_ChuBanShe = Request.Form("ctrl_ChuBanShe")

    If (errMessage <> "") Then
        Call Javascript("showMsg('"&replace(errMessage,"<br>","\n\n")&"'); goUrl('-1','')")
        Response.End()
    End If
求看看错在那里!!

板凳


这里事演示地址:http://wangyu.web.dns12580.com/cert/sreach-ts.html[url=http://]http://wangyu.web.dns12580.com/cert/sreach-ts.html[/url]

我来回复

您尚未登录,请登录后再回复。点此登录或注册