| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 764 人关注过本帖
标题:请aspic老师再帮帮学生!----如何把这个"二合一"页面分成"搜索页面"和"显示页 ...
只看楼主 加入收藏
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
结帖率:87.5%
收藏
已结贴  问题点数:20 回复次数:8 
请aspic老师再帮帮学生!----如何把这个"二合一"页面分成"搜索页面"和"显示页面"?
分离手术----如何把这个"二合一"页面分成"搜索页面"和"显示页面"?就是说,把搜索框插入任何一个页面,只要点击"搜索"就可转到"显示页面"显示搜索到的信息?谢谢!

<!--#include file="CONDB.asp"-->
<!--#include file="Cls\Paging.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Asp搜索分页</title>
<style type="text/css">
<!--
.style2 {font-size: 18px}
.style3 {font-size: 16px}
.style5 {
    color: #00FF00;
    font-weight: bold;
    font-size: 16px;
}
.style6 {
    color: #0000FF;
    font-size: 16px;
}
-->
</style>
<script language="javascript">
<!--
function Page_Submit()
{
   if(document.SearchForm.searchTxt.value=="")
   {
       alert('请输入搜索词');
       return false;
   }
   document.SearchForm.submit();
}
function Page_Load()
{
 <%
   Dim oPage'定义分页对象'
   Dim rsTest'定义ADODB.RecordSet对象'
   Dim TErrM'定义临时错误信息对象'
   Dim RecordCount
   On Error Resume Next
   Set oPage=New Paging'初始化分页对象'
   Set rsSearch=Server.CreateObject("ADODB.RecordSet")'初始化ADODB.RecordSet对象'
   '分页对象属性设置'
   IF Request("searchTxt")<>"" Then
      oPage.URLStr="search.asp?searchTxt="&Request("searchTxt")&"&"'设置要分页的页面URL必须加?号'
      '如果需要自定义参数则设置为'
      'oPage.URLStr="PagingTest.asp?ParamentName=ParamentValue&"'
      '这样的格式'
      oPage.SQLStr="select * From list where title like '%"&Request("searchTxt")&"%' Or word like '%"&Request("searchTxt")&"%' "'设置页面的SQL语句'
      oPage.PageSize=10'设置每页显示的记录数'
      oPage.CurrentPage=Clng(Request("page"))'得到当前页号'
      TErrM=oPage.InitF(rsSearch,con)'分页类初始化方法必须执行'
      IF TErrM<>"" Then'分页类错误判断'
         Response.Write "alert('"&TErrM&"');"
      End IF
      IF Not rsSearch.EOF Then
         RecordCount=rsSearch.RecordCount
      Else
         RecordCount=0
      End IF     
   End IF
%>
}
-->
</script>
</head>

<body>

<table width="558" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="558" height="82" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="558" height="41">&nbsp;</td>
        </tr>
        <tr>
          <td height="25" valign="top"><div align="center">
            <form name="SearchForm" method="get" action="search.asp">
            <input type="text" name="searchTxt">
            <input type="button" name="Submit" onClick="Page_Submit();" value="搜索">
            </form>
          </div></td>
        </tr>
        <tr>
          <td height="16" valign="top" bgcolor="#66CCCC"><div align="right">共搜索到<%=RecordCount%>条数据</div></td>
        </tr>
                </table></td>
  </tr>
  <tr>
    <td height="77" valign="top">
<%
    Dim iPage
    '判断是否搜索到内容
    IF Request("searchTxt")<>"" Then
       IF rsSearch.EOF Then
          Response.Write "没有找到任何内容"
       Else
          For iPage=0 To rsSearch.PageSize
%>    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="558" height="19" valign="top"><span class="style2"><a href="<%=rsSearch("url")%>" title="<%=rsSearch("title")%>" ><%=Replace(rsSearch("title"),Request("searchTxt"),"<font color=red>"&Request("searchTxt")&"</font>")%></a></span></td>
        </tr>
        <tr>
          <td height="41" valign="top"> <span class="style3"><%=Replace(rsSearch("word"),Request("searchTxt"),"<font color=red>"&Request("searchTxt")&"</font>")%></span><br></td>
        </tr>
        <tr>
          <td height="17" valign="top"><span class="style5"><%=rsSearch("url")%></span></td>
        </tr>
      </table>
<%
             rsSearch.MoveNext
             IF rsSearch.EOF Then Exit For
          Next
       End IF
    End IF   
%>    </td>
  </tr>
  <tr>
    <td height="13" valign="top"><span class="style6">共<%=rsSearch.PageCount%>页 当前第<%=Request("page")%>页 <a href="search.asp?page=1&PageP=10&searchTxt=<%=Request("searchTxt")%>" title="第一页" target="_self"><font face=webdings>9</font></a>
    <%
        Response.Write oPage.PagingControl(rsSearch,Request("PageP"))'分页控制方法其中Request("PageP")固定写法
    %>
    </span></td>
  </tr>
  <tr>
    <td height="309">&nbsp;</td>
  </tr>
</table>
<%
   rsSearch.Close
   con.close
   Set rsSearch=Nothing
   Set con=Nothing
%>
</body>
</html>


[ 本帖最后由 tepnidh 于 2009-9-15 19:59 编辑 ]
搜索更多相关主题的帖子: 老师 页面 学生 aspic 
2009-09-15 07:18
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
程序代码:
<!--#include file="CONDB.asp"--> 
<!--#include file="Cls\Paging.asp"--> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>Asp搜索分页</title> 
<style type="text/css"> 
<!-- 
.style2 {font-size: 18px} 
.style3 {font-size: 16px} 
.style5 { 
    color: #00FF00; 
    font-weight: bold; 
    font-size: 16px; 
} 
.style6 { 
    color: #0000FF; 
    font-size: 16px; 
} 
--> 
</style> 
</head> 
 
<body> 
 
<table width="558" border="0" cellpadding="0" cellspacing="0"> 
  <!--DWLayoutTable--> 
  <tr> 
    <td width="558" height="82" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0"> 
        <!--DWLayoutTable--> 
        <tr> 
          <td width="558" height="41">&nbsp;</td> 
        </tr> 
        <tr> 
          <td height="25" valign="top"><div align="center"> 
            <form name="SearchForm" method="get" action="search.asp">  
            <input type="text" name="searchTxt"> 
            <input type="button" name="Submit" onClick="Page_Submit();" value="搜索"> 
            </form> 
          </div></td> 
        </tr> 
        <tr> 
          <td height="16" valign="top" bgcolor="#66CCCC"><div align="right">共搜索到<%=RecordCount%>条数据</div></td> 
        </tr> 
                </table></td> 
  </tr> 
  <tr> 
    <td height="77" valign="top"> 
<% 
    Dim iPage 
    '判断是否搜索到内容 
    IF Request("searchTxt")<>"" Then 
       IF rsSearch.EOF Then 
          Response.Write "没有找到任何内容" 
       Else 
          For iPage=0 To rsSearch.PageSize 
%>    <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
        <!--DWLayoutTable--> 
        <tr> 
          <td width="558" height="19" valign="top"><span class="style2"><a href="<%=rsSearch("url")%>" title="<%=rsSearch("title")%>" ><%=Replace(rsSearch("title"),Request("searchTxt"),"<font color=red>"&Request("searchTxt")&"</font>")%></a></span></td> 
        </tr> 
        <tr> 
          <td height="41" valign="top"> <span class="style3"><%=Replace(rsSearch("word"),Request("searchTxt"),"<font color=red>"&Request("searchTxt")&"</font>")%></span><br></td> 
        </tr> 
        <tr> 
          <td height="17" valign="top"><span class="style5"><%=rsSearch("url")%></span></td> 
        </tr> 
      </table> 
<% 
             rsSearch.MoveNext 
             IF rsSearch.EOF Then Exit For 
          Next 
       End IF 
    End IF     
%>    </td> 
  </tr> 
  <tr> 
    <td height="13" valign="top"><span class="style6">共<%=rsSearch.PageCount%>页 当前第<%=Request("page")%>页 <a href="search.asp?page=1&PageP=10&searchTxt=<%=Request("searchTxt")%>" title="第一页" target="_self"><font face=webdings>9</font></a> 
    <% 
        Response.Write oPage.PagingControl(rsSearch,Request("PageP"))'分页控制方法其中Request("PageP")固定写法 
    %> 
    </span></td> 
  </tr> 
  <tr> 
    <td height="309">&nbsp;</td> 
  </tr> 
</table> 
<% 
   rsSearch.Close 
   con.close 
   Set rsSearch=Nothing 
   Set con=Nothing 
%> 
</body> 
</html>
程序代码:
<!--#include file="CONDB.asp"-->  
<!--#include file="Cls\Paging.asp"-->  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=gb2312">  
<title>Asp搜索分页</title>  
<style type="text/css">  
<!--  
.style2 {font-size: 18px}  
.style3 {font-size: 16px}  
.style5 {  
    color: #00FF00;  
    font-weight: bold;  
    font-size: 16px;  
}  
.style6 {  
    color: #0000FF;  
    font-size: 16px;  
}  
-->  
</style>  
<script language="javascript">  
<!--  
function Page_Submit()  
{  
   if(document.SearchForm.searchTxt.value=="")  
   {  
       alert('请输入搜索词');  
       return false;  
   }  
   document.SearchForm.submit();  
}  
</script>  
</head>  
  
<body>  
<table width="100%" border="0" cellpadding="0" cellspacing="0">   
    <tr>  
        <td width="558" height="41">&nbsp;</td>  
    </tr>  
    <tr>  
        <td height="25" valign="top"><div align="center">  
            <form name="SearchForm" method="get" action="search.asp">   
            <input type="text" name="searchTxt">  
            <input type="button" name="Submit" onClick="Page_Submit();" value="搜索">  
            </form>  
          </div></td>  
        </tr>  
        <tr>  
          <td height="16" valign="top" bgcolor="#66CCCC"><div align="right">共搜索到<%=RecordCount%>条数据</div></td>  
        </tr>  
</table> 
</body>
</html>
2009-09-15 08:44
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
收藏
得分:0 
aspic老师,您好!我测试了一下,没有成功!请老师再帮帮学生吧!!多谢!
点击"搜索",报错:
错误类型:
Microsoft VBScript 运行时错误 (0x800A01A8)
缺少对象: ''
/AspSearch/search.asp, 第 54 行


...........................
<%
    Dim iPage
    '判断是否搜索到内容
    IF Request("searchTxt")<>"" Then
 IF rsSearch.EOF Then ...................................................第54行
          Response.Write "没有找到任何内容"
       Else
          For iPage=0 To rsSearch.PageSize
%>
.............................
2009-09-15 20:03
sunfishy
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:311
专家分:163
注 册:2007-6-29
收藏
得分:0 
你如果完全引用2楼的代码的话
要注意下没有定义rsSearch

sql=....
set rsSearch=server.createobject("adodb.recordset")
rsSearch.open sql,conn,1,1

.cn
2009-09-15 20:29
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
收藏
得分:0 
回复 4楼 sunfishy
sunfishy老师,您好,谢谢您的帮助!我是菜菜鸟,能否帮我把这个程序搞完整啊?谢谢!您就辛苦一下,好吗?谢谢......
2009-09-15 20:43
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:20 
程序代码:
<!--#include file="CONDB.asp"-->  
<!--#include file="Cls\Paging.asp"-->
<% 
   Dim oPage'定义分页对象' 
   Dim rsTest'定义ADODB.RecordSet对象' 
   Dim TErrM'定义临时错误信息对象' 
   Dim RecordCount 
   On Error Resume Next 
   Set oPage=New Paging'初始化分页对象' 
   Set rsSearch=Server.CreateObject("ADODB.RecordSet")'初始化ADODB.RecordSet对象' 
   '分页对象属性设置' 
   IF Request("searchTxt")<>"" Then 
      oPage.URLStr="search.asp?searchTxt="&Request("searchTxt")&"&"'设置要分页的页面URL必须加?号' 
      '如果需要自定义参数则设置为' 
      'oPage.URLStr="PagingTest.asp?ParamentName=ParamentValue&"' 
      '这样的格式' 
      oPage.SQLStr="select * From list where title like '%"&Request("searchTxt")&"%' Or word like '%"&Request("searchTxt")&"%' "'设置页面的SQL语句' 
      oPage.PageSize=10'设置每页显示的记录数' 
      oPage.CurrentPage=Clng(Request("page"))'得到当前页号' 
      TErrM=oPage.InitF(rsSearch,con)'分页类初始化方法必须执行' 
      IF TErrM<>"" Then'分页类错误判断' 
         Response.Write "alert('"&TErrM&"');" 
      End IF 
      IF Not rsSearch.EOF Then  
         RecordCount=rsSearch.RecordCount 
      Else 
         RecordCount=0 
      End IF      
   End IF 
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=gb2312">  
<title>Asp搜索分页</title>  
<style type="text/css">  
<!--  
.style2 {font-size: 18px}  
.style3 {font-size: 16px}  
.style5 {  
    color: #00FF00;  
    font-weight: bold;  
    font-size: 16px;  
}  
.style6 {  
    color: #0000FF;  
    font-size: 16px;  
}  
-->  
</style>  
</head>  
 
<body>  
 
<table width="558" border="0" cellpadding="0" cellspacing="0">  
  <!--DWLayoutTable-->  
  <tr>  
    <td width="558" height="82" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">  
        <!--DWLayoutTable-->  
        <tr>  
          <td width="558" height="41">&nbsp;</td>  
        </tr>  
        <tr>  
          <td height="25" valign="top"><div align="center">  
            <form name="SearchForm" method="get" action="search.asp">   
            <input type="text" name="searchTxt">  
            <input type="button" name="Submit" onClick="Page_Submit();" value="搜索">  
            </form>  
          </div></td>  
        </tr>  
        <tr>  
          <td height="16" valign="top" bgcolor="#66CCCC"><div align="right">共搜索到<%=RecordCount%>条数据</div></td>  
        </tr>  
                </table></td>  
  </tr>  
  <tr>  
    <td height="77" valign="top">  
<%  
    Dim iPage  
    '判断是否搜索到内容  
    IF Request("searchTxt")<>"" Then  
       IF rsSearch.EOF Then  
          Response.Write "没有找到任何内容"  
       Else  
          For iPage=0 To rsSearch.PageSize  
%>    <table width="100%" border="0" cellpadding="0" cellspacing="0">  
        <!--DWLayoutTable-->  
        <tr>  
          <td width="558" height="19" valign="top"><span class="style2"><a href="<%=rsSearch("url")%>" title="<%=rsSearch("title")%>" ><%=Replace(rsSearch("title"),Request("searchTxt"),"<font color=red>"&Request("searchTxt")&"</font>")%></a></span></td>  
        </tr>  
        <tr>  
          <td height="41" valign="top"> <span class="style3"><%=Replace(rsSearch("word"),Request("searchTxt"),"<font color=red>"&Request("searchTxt")&"</font>")%></span><br></td>  
        </tr>  
        <tr>  
          <td height="17" valign="top"><span class="style5"><%=rsSearch("url")%></span></td>  
        </tr>  
      </table>  
<%  
             rsSearch.MoveNext  
             IF rsSearch.EOF Then Exit For  
          Next  
       End IF  
    End IF      
%>    </td>  
  </tr>  
  <tr>  
    <td height="13" valign="top"><span class="style6">共<%=rsSearch.PageCount%>页 当前第<%=Request("page")%>页 <a href="search.asp?page=1&PageP=10&searchTxt=<%=Request("searchTxt")%>" title="第一页" target="_self"><font face=webdings>9</font></a>  
    <%  
        Response.Write oPage.PagingControl(rsSearch,Request("PageP"))'分页控制方法其中Request("PageP")固定写法  
    %>  
    </span></td>  
  </tr>  
  <tr>  
    <td height="309">&nbsp;</td>  
  </tr>  
</table>  
<%  
   rsSearch.Close  
   con.close  
   Set rsSearch=Nothing  
   Set con=Nothing  
%>  
</body> 
程序代码:
<!--#include file="CONDB.asp"-->   
<!--#include file="Cls\Paging.asp"-->   
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=gb2312">   
<title>Asp搜索分页</title>   
<style type="text/css">   
<!--   
.style2 {font-size: 18px}   
.style3 {font-size: 16px}   
.style5 {   
    color: #00FF00;   
    font-weight: bold;   
    font-size: 16px;   
}   
.style6 {   
    color: #0000FF;   
    font-size: 16px;   
}   
-->   
</style>   
<script language="javascript">   
<!--   
function Page_Submit()   
{   
   if(document.SearchForm.searchTxt.value=="")   
   {   
       alert('请输入搜索词');   
       return false;   
   }   
   document.SearchForm.submit();   
}   
</script>   
</head>   
   
<body>   
<table width="100%" border="0" cellpadding="0" cellspacing="0">    
    <tr>   
        <td width="558" height="41">&nbsp;</td>   
    </tr>   
    <tr>   
        <td height="25" valign="top"><div align="center">   
            <form name="SearchForm" method="get" action="search.asp">    
            <input type="text" name="searchTxt">   
            <input type="button" name="Submit" onClick="Page_Submit();" value="搜索">   
            </form>   
          </div></td>   
        </tr>   
        <tr>   
          <td height="16" valign="top" bgcolor="#66CCCC"><div align="right">共搜索到<%=RecordCount%>条数据</div></td>   
        </tr>   
</table>  
</body> 
</html>
2009-09-16 10:02
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
收藏
得分:0 
aspic老师,您好!
当输入数据库中存在的关键词后,点击搜索能正常转到显示页面.并能正确显示所要查询的信息.但仍然存在一些问题:1.当输入数据库中无这个关键词时,则在显示页面显示这样的语句:"alert('BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。'); "(显示这样的词句,在页面中很不雅观)
2.当把显示页面后退一步之后,搜索页面中的搜索框中的关键词仍存在,此时再点击"搜索"却无法转到显示页面,并报错:"网页上有错误",只有再重新输入这个关键词或其它关键词才能转到显示页面,不知是什么原因?

这样说,可能没能说清楚,这样吧,老师,我把源程序上传给您,如果您有时间的话,就帮帮学生吧,如果您忙就另找时间帮帮学生吧!学生所要的效果是:搜索页面和显示页面分开,并可以把搜索页面插入到任何页面.点击"搜索"转到显示页面.

AspSearch.rar (14.13 KB)
2009-09-16 20:36
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
这个东西又不是我写的 你问写的人比较清楚吧
2009-09-17 08:38
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
收藏
得分:0 
aspic老师,您好!学生知道,您很忙,也是一位编程专家,您就帮帮我吧!您帮助我多次了,我真的很感激您,学生在想,这个问题对于您来讲是很容易解决的,渴望能得到您的再次帮助!!谢谢!
2009-09-17 09:29
快速回复:请aspic老师再帮帮学生!----如何把这个"二合一"页面分成"搜索页面"和" ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024640 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved