zoukankan      html  css  js  c++  java
  • asp多行多列的分页以及form中传递特殊字符的应用(1)

    asp多行多列的分页以及form中传递特殊字符的应用(1)
    今天心情还不错,写点东西,多行多列的分页
    先给个例子,我一直在使用的
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">

      <tr>
        <td  width="100%">
          <%
    Response.Write"<tr><td valign='top'>"  
    Response.Write"<table width='93%' border='0' cellspacing='0' cellpadding='8' align='center'>"

    Dim ipagecount
    Dim ipagecurrent
    Dim strorderBy
    Dim irecordsshown 
    if request.querystring("page")="" then
    ipagecurrent=1
    else
    ipagecurrent=cint(request.querystring("page"))
    end if

    '下面这段写得很乱,就是满足条件SQL选择
    if bigclassname="" then
    sql = "Select articleid,product_id,title,bigclassname,smallclassname,minclassname,DefaultPicUrl,passed,updatetime From product where passed=1 Order By updatetime desc"
    else
    if smallclassname="" then
    sql = "Select articleid,product_id,title,bigclassname,smallclassname,minclassname,DefaultPicUrl,passed,updatetime From product where passed=1  Order By updatetime desc"
    else
    if minclassname="" then
    sql = "Select articleid,product_id,title,bigclassname,smallclassname,minclassname,DefaultPicUrl,passed,updatetime From product where passed=1 and smallclassname='"&smallclassname&"' Order By updatetime desc"
    else
    sql = "Select articleid,product_id,title,bigclassname,smallclassname,minclassname,DefaultPicUrl,passed,updatetime From product where  passed=1  and smallclassname='"&smallclassname&"'and minclassname='"&minclassname&"' Order By updatetime desc"
    end if
    end if
    end if


    Set rsArticle = Server.CreateObject("ADODB.Recordset")
    rsArticle.pagesize = 8
    '每页个数
    rsArticle.cachesize = 8
    rsArticle.open sql,conn,1,1
    ipagecount = rsArticle.pagecount

    If ipagecurrent > ipagecount Then ipagecurrent = ipagecount
    If ipagecurrent < 1 Then ipagecurrent = 1
    if ipagecount=0 then
    response.write "<tr><td align='center'> 没有产品</tr></td>"
    else
    rsArticle.absolutepage = ipagecurrent
    irecordsshown = 0
    do while irecordsshown<8 and NOT rsArticle.EOF
    Response.Write"<tr align='center'>"

    for i=1 to 2
    '最关键得地方,2就是两列,3就是三列,以次类推

    Response.Write"<td width='50%'>"
    '这里和上面对应,当是两列得是宽为50%,3得时候是33%就是(1/N*100)%
    if not rsArticle.eof then

    %>

    <table width="100%" height="100" border="1" cellpadding="1" cellspacing="0" bordercolor=#ffffff bordercolordark=#CEE5F3 bordercolorlight=#FFFFFF>
      <tr>
        <td width="35%" valign="middle"><table width="100%" height="90" border="0" align="center" cellpadding="0" cellspacing="0" >
          <tr>
            <td align="center"><a href="productshow.asp?articleid=<%=rsarticle("articleid")%>&bigclassname=<%=rsarticle("bigclassname")%>&smallclassname=<%=rsarticle("smallclassname")%>&minclassname=<%=rsarticle("minclassname")%>" target="_blank" class="my"><img src="<%=rsArticle("DefaultPicUrl")%>" width="90" height="90" border="0"></a></td>
          </tr>
        </table></td>
        <td width="65%" valign="top"><table width="100%" height="70" border="0" cellpadding="0" cellspacing="2" class="style4" >
          <tr>
            <td width="39%">&nbsp;</td>
            <td width="61%">&nbsp;</td>
          </tr>
          <tr>
            <td bgcolor="#efefef">产品编号</td>
            <td bgcolor="#efefef"><%=rsarticle("product_id")%></td>
          </tr><!--
          <tr>
            <td bgcolor="#efefef">名称:</td>
            <td bgcolor="#efefef" ><% if len(rsarticle("title"))>20 then%> <%=left(rsarticle("title"),17)%>...<%else%><%=rsarticle("title")%>
    <%end if%></td>
          </tr>-->
          <tr>
            <td colspan="2" align="right" ><a href="productshow.asp?articleid=<%=rsarticle("articleid")%>&bigclassname=<%=rsarticle("bigclassname")%>&smallclassname=<%=rsarticle("smallclassname")%>&minclassname=<%=rsarticle("minclassname")%>" target="_blank" class="my">详细信息</a></td>
            </tr>
        </table></td>
      </tr>
    </table>

    <%
    end if
    irecordsshown = irecordsshown +1
    rsArticle.movenext


    next

    Response.Write"</tr>"
    loop
    end if
    rsArticle.Close
    set rsArticle=nothing
    Response.Write"</table></td></tr>"
    Response.Write"<tr><td valign='bottom'>"
    '以下是get传递参数会使用到的,具体什么意思各位不懂就百度一下
    action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")

        query = Split(Request.ServerVariables("QUERY_STRING"), "&")
        For Each x In query
            a = Split(x, "=")
            If StrComp(a(0), "page", vbTextCompare) <> 0 Then
                temp = temp & a(0) & "=" & a(1) & "&"
            End If
        Next
    Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;"">" & vbCrLf )
    Response.Write"<table width='96%' border='0' cellspacing='0' cellpadding='0' class='style10'><tr><td valign='bottom'><tr><td height='20' align='right'>"%><% Response.Write"  8/页. <font color=ff0000>"&ipagecurrent&"</font>/"&ipagecount&"&nbsp;<td></tr><tr><td align='right'>"

    if ipagecurrent=1 then
    Response.Write"首页| "
    else

    Response.Write"<a href='product.asp?bigclassname="&bigclassname&"&smallclassname="&smallclassname&"&minclassname="&minclassname&"&page=1' class='my'>首页</a> | "
    end if
    if ipagecurrent=1 then
    Response.Write"上一页.| "
    else
      
    Response.Write"<a href='product.asp?bigclassname="&bigclassname&"&smallclassname="&smallclassname&"&minclassname="&minclassname&"&page="&ipagecurrent-1&"' class='my'>上一页.</a> | "
      
    end if
    if ipagecount>ipagecurrent then
    Response.Write"<a href='product.asp?bigclassname="&bigclassname&"&smallclassname="&smallclassname&"&minclassname="&minclassname&"&page="&ipagecurrent+1&"' class='my'>下一页.</a> "
    else
    Response.Write"下一页."
    end if
    if ipagecount>ipagecurrent then
    Response.Write"| <a href='product.asp?bigclassname="&bigclassname&"&smallclassname="&smallclassname&"&minclassname="&minclassname&"&page="&ipagecount&"' class='my'>尾页.</a> "
    else
    Response.Write"| 尾页."
    end if
    Response.Write(" goto" & "<INPUT CLASS=wenbenkuang TYEP=TEXT NAME=page SIZE=2 Maxlength=5 VALUE=" & page & ">" & ""  & vbCrLf & "<INPUT CLASS=go-wenbenkuang type=submit value=GO>")
        Response.Write("</form>" & vbCrLf )
      
    Response.Write"</table></td></tr>"
    %>
         </td>
     </tr>
     </TABLE>

    说是写东西,其实就是将我用的代码发出来了,希望对需要的朋友有帮助.吃饭了,下次再发另外的方法.呵呵.

  • 相关阅读:
    常用颜色
    在VS2010中打开VS2012的项目
    vs2012 断点不能调试
    Setup Factory 打包.netframework 2.0
    Access 中数据库操作时提示from子句语法错误
    vs2012 .netFramwork2.0发布到xp
    c# access插入null值
    Visual Studio安装卸载模板
    Codeforces 455D
    ACdream 1157 (cdq分治)
  • 原文地址:https://www.cnblogs.com/zerogo/p/2209405.html
Copyright © 2011-2022 走看看