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

<!--#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-17 17:36 编辑 ]
搜索更多相关主题的帖子: content include PUBLIC style title 
2009-09-17 17:35
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:80 
怎么还是这个问题~
程序代码:
search.asp 如下代码为搜索结果页
<!--#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> 
<% 
   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 
%> 
</head> 
 
<body> 
 
<table width="558" border="0" cellpadding="0" cellspacing="0"> 
  <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>
程序代码:
如下代码为搜索表单页 可嵌入任意地方 但是要注意带上那段验证的js
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. 
<html xmlns="http://www. 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>Asp搜索分页</title> 
<script language="javascript"> 
function Page_Submit() 
{ 
   if(document.SearchForm.searchTxt.value=="") 
   { 
       alert('请输入搜索词'); 
       return false; 
   } 
   document.SearchForm.submit(); 
} 
</script> 
</head> 
 
<body> 
<form name="SearchForm" method="get" action="search.asp">  
    <input type="text" name="searchTxt"> 
    <input type="button" name="Submit" onClick="Page_Submit();" value="搜索"> 
</form> 
</body> 
</html>
2009-09-18 08:41
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
收藏
得分:0 
回复 2楼 aspic
aspic老师,您好!在您的帮助,支持下,应用了您写的程序,一次测试成功!!学生真的好高兴啊!看来,编程论坛我没有选错,aspic老师我更没有选错!我是一个非常菜菜的小菜鸟,但您一点都不瞧不起我,非常耐心地帮助我!大恩不言谢,但学生还是要说一声,谢谢老师!
祝老师及家人幸福快乐!!
我这里只有80分,加给您,略表一点心意!
2009-09-18 17:45
快速回复:[分离手术]----如何把这个"二合一"页面分成"搜索页面"和"显示页面"?[加 ...
数据加载中...
 
   



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

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