⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search_result.asp

📁 一个关于网站权限管理的经典例子,适合初学者
💻 ASP
字号:
<% Option explicit %>
<!-- #Include file="./connects.inc"-->
<!-- #Include file="../globals.inc"-->

<Html>
<Head>
  <title><%=sPageTitle%></title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  <link href="../style/style.css" rel="stylesheet">
  <style type="text/css">
   .txt1 { font-family: "宋体"; font-size: 9pt; color: #023361 ; background-color: #efefef; border-color: #efefef #595959 #696A6B #DADADA; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
  </style>
  <script language="javascript" src="../../scripts/functions.js"></script>
  <Script language="javascript" src="../../scripts/table_cell_color.js"></Script>
  <script language="javascript">
  //增加记录:
    function Add()
    { this.location="add.asp";
    }

  //函数:统计选择了几条记录:
   function HowManySelected(theForm)
   {
    var num=0;
    for (var i=0;i<theForm.elements.length;i++)
    {
     if(theForm.elements[i].type=='checkbox' && theForm.elements[i].checked==true)
       num=num+1;
    }
    return num;
   }

   //修改记录:
   function Modi()
   {
    no=HowManySelected(frm1);
    switch (no)
    {
     case 0:
       alert("请选择一条需要修改的记录");
       break;
     case 1:
       frm1.theOption.value='Modify';
       frm1.submit();
       break;
     default:
       alert("注意:一次只能修改一条记录!");
    }
   }

   //删除记录:
   function Del()
   {
     alert("本测试代码不允许删除用户!")
     return;

     no=HowManySelected(frm1);
     switch (no)
     {
      case 0:
        alert("请选择即将删除的记录");
        break;
      default:
        if (confirm("即将删除选定的记录,确定吗?\n\n注意:记录删除后无法恢复!"))
        { frm1.theOption.value='Delete';
          frm1.submit();
        }
     }
   }

   //
   function Search()
   { document.location="search.asp";
   }

   //
   function Refresh()
   { document.location="lists.asp";
   }

   //
   function Help()
   { document.location="../helps.asp#normal";
   }

   //
   function Goback()
   { document.location="lists.asp";
   }

   //选择/取消选择所有的记录:
   function SelectAllorNot(obj)
   {
     if (obj.checked)
     {for (var i=0;i<frm1.elements.length;i++)
      {if(frm1.elements[i].type=='checkbox')
        frm1.elements[i].checked=true;
      }
     }
     else
     {for (var i=0;i<frm1.elements.length;i++)
      {if(frm1.elements[i].type=='checkbox')
        frm1.elements[i].checked=false;
      }
     }
   }
  </script>
</head>

<Body topmargin="5" leftmargin="0" background="../images/bg.gif">

<table width="835" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td width="9"><img src="../images/left.gif" width="9" height="21"></td>
    <td background="../images/middle.gif"><b>帐户管理</b>-查找结果</td>
    <td width="9"><img src="../images/right.gif" width="9" height="21"></td>
  </tr>
</table>

<table width="835" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="23457F">
  <tr>
    <td bgcolor="F2F8FD">
    <!--Begin----------------------------------------------->

    <!--菜单:---------------->
    <table border="0" width="450" cellspacing="0" cellpadding="0" align="center">
      <tr height=30>
        <td background=../images/menu1.gif width=77>&nbsp;</td>
        <td background=../images/menu3.gif>
          <table cellpadding="0" cellspacing="0" height="16" align=center>
           <tr align="center" nowrap>
            <td width="48" class="txt1"><a href="javascript:Goback();" title="返回"><img src="../images/goback.gif" width="16" height="16" border="0">返回</a></td>
            <td width="48" class="txt1"><a href="javascript:Modi();" title="修改"><img src="../images/Modi.gif" width="16" height="16" border="0">修改</a></td>
            <td width="48" class="txt1"><a href="javascript:Del();" title="删除"><img src="../images/del.gif" width="16" height="16" border="0">删除</a></td>
            <td width="48" class="txt1"><a href="javascript:Search();" title="查找"><img src="../images/find.gif" width="16" height="16" border="0">查找</a></td>
            <td width="48" class="txt1"><a href="javascript:Help();" title="帮助"><img src="../images/help1.gif" width="16" height="16" border="0">帮助</a></td>
            <td>&nbsp;<input type="checkbox" id="selectall" OnClick="SelectAllorNot(this)"><label for=selectall>全选</label></td>
           </tr>
          </table>
        </td>
        <td background=../images/menu2.gif width=19>&nbsp;</td>
      </tr>
    </table>

    <!--内容列表:-------------->
    <%
      Dim sSQL, rs, Page, iPage, sAccountname, sUsername, sRemark, sCondition, urlCondition

      sAccountname=request("accountname")
      sUsername=request("username")
      sRemark=request("remark")
      sCondition=""

      if sAccountname<>"" then
        sCondition="f_accountname like '%"& sAccountname &"%' and "
      end if
      if sUsername<>"" then
        sCondition=sCondition & "f_username like '%"& sUsername &"%' and "
      end if
      if sRemark<>"" then
        sCondition=sCondition & "f_remark like '%"& sRemark &"%'"
      end if

      if right(sCondition,4)="and " then
        sCondition=trim(left(sCondition,len(sCondition)-4)) '截断尾部可能的 "and " 字符串
      end if

      if len(trim(sCondition))>0 then   '判断条件字符串是否为空
        sCondition=" where " & sCondition
      else
        sCondition=""
      end if

      sSQL="select * from tabAccountInfo " & sCondition & " order by f_i_orderid"
      'response.write sSQL
      Set rs = Server.CreateObject("ADODB.Recordset")
      rs.Open sSQL, sConn, 1, 1
      if rs.eof and rs.bof then    '记录集为空
        response.write("<br><center>【<font color=red>当前数据库中没有记录</font>】</center><br>")
        response.end
      end if

      rs.PageSize = nRecordsPerPage0   '页尺寸
      if trim(Request("Page"))="" then
        page=1
      else
        Page = CLng(Request("Page"))   'Page(当前页码)为上级调用者传递来的参数
      end if

      If Page < 1 Then Page = 1        '第一次打开时 Page=0
      If Page > rs.PageCount Then Page = rs.PageCount    '输入页码时,有可能 Page 大于总页码
    %>

    <table border=1 width="828" align="center" cellpadding=0 cellspacing="0" bordercolor="#CECFFF" bordercolorlight="#CECFFF" bordercolordark="#ffffff">
    <Form name="frm1" method="POST" action="Modi_del_options.asp">
    <input name="theOption" type=hidden value="">
      <tr align=center nowrap bgcolor=#cccccc height=25>
        <td width="40"><b>选择</b></td>
        <td width="48"><b>排序号</b></td>
        <td width="40"><b>编号</b></td>
        <td width="150"><b>帐户名</b></td>
        <td width="80"><b>口令</b></td>
        <td width="100"><b>帐户类型</b></td>
        <td width="120"><b>用户姓名</b></td>
        <td width="250"><b>备注</b></td>
      </tr>
     <% '显示本页的记录们
      rs.AbsolutePage = Page
      For iPage = 1 To rs.PageSize
     %>
      <tr onMouseOut="mouseout_tr(this)" onMouseOver="mouseover_tr(this)">
       <td align="center"><input type="checkbox" name=chk<%=trim(rs("f_i_autoid"))%>></td>
       <td align="center">&nbsp;<%=trim(rs("f_i_orderid"))%></td>
       <td align="center">&nbsp;<%=trim(rs("f_accountid"))%></td>
       <td>&nbsp;<%=rs("f_accountname")%></td>
       <td align="center">&nbsp;******</td>
       <td>&nbsp;<%=rs("f_accounttype")%></td>
       <td>&nbsp;<%=rs("f_username")%></td>
       <td title="<%=rs("f_remark")%>">&nbsp;<%=formatstr(rs("f_remark"),40)%></td>
      </tr>
    <%
        rs.MoveNext
        If rs.EOF Then Exit For
      Next
    %>
     </Form>
    </table>

    <Table width=800 align=right border=0>
    <tr>
     <td width=400 align=left valign=bottom>共检索到 <font color=blue><%=rs.recordcount%></font> 条记录&nbsp; </td>
     <td align=right valign=bottom>
     <%
      '组合传递的参数序列:
      urlCondition="&accountname=" & sAccountname & "&username=" & sUsername & "&remark=" & sRemark
      'response.write urlCondition

      '分页:
      if Page=1 and rs.PageCount=1 Then
        Response.Write " <font color=#cccccc> 第一页 </font> "
        Response.Write " <font color=#cccccc> 上一页 </font> "
        Response.Write " <font color=#cccccc> 下一页 </font> "
        Response.Write " <font color=#cccccc> 最末页 </font> "
      else
        If Page = 1 Then
          Response.Write " <font color=#cccccc> 第一页 </font> "
          Response.Write " <font color=#cccccc> 上一页 </font> "
          Response.Write " <A HREF=search_result.asp?Page=" & (Page+1) & urlCondition & "> 下一页 </A>"
          Response.Write " <A HREF=search_result.asp?Page=" & rs.PageCount & urlCondition & "> 最末页 </A>"
        End If
        If Page>1 and page<rs.PageCount Then
          Response.Write " <A HREF=search_result.asp?Page=1" & urlCondition & ">第一页</A>"
          Response.Write " <A HREF=search_result.asp?Page=" & (Page-1) & urlCondition & "> 上一页 </A>"
          Response.Write " <A HREF=search_result.asp?Page=" & (Page+1) & urlCondition & "> 下一页 </A>"
          Response.Write " <A HREF=search_result.asp?Page=" & rs.PageCount & urlCondition & "> 最末页 </A>"
        End if
        If Page = rs.PageCount Then
          Response.Write " <A HREF=search_result.asp?Page=1" & urlCondition & "> 第一页 </A>"
          Response.Write " <A HREF=search_result.asp?Page=" & (Page-1) & urlCondition & "> 上一页</A>"
          Response.Write " <font color=#cccccc> 下一页 </font> "
          Response.Write " <font color=#cccccc> 最末页 </font> "
        End If
      end if
     %>
    </td>

    <script language="javascript">
      function GotoPage()
      { if (number_Validator(page))
          document.location='search_result.asp?page='+page.value+'<%=urlCondition%>';
      }
    </script>

    <td align=center>
       页码:<font color="Red"><%=Page%>/<%=rs.PageCount%></font>&nbsp;&nbsp;
       跳转到:<input name="page" type="text" SIZE="3" maxlength=8>&nbsp;
              <input type="image" src="../images/go.gif" width="45" height="18" onclick="GotoPage();">
    </td></tr>
    </table>

    <%
      rs.close
      set rs=nothing
    %>

    <!--End----------------------------------------------->
   </td>
  </tr>
</table>

</Body>
</Html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -