![]() |
#2
yms1232008-02-04 17:54
也就是说每行5个来排列?
其实分页算法个人认为不仅可以用在分页上,这里也可以灵活运用 最近写的一个灵活运用分页算法的例子 function PagesClass() { this.PSize=0; this.PageCount=0; this.PCount=0; this.PCurrent=0; this.PNumAry; this.getDInt=function(NumA,NumB) { var NumC; if(NumA%NumB==0) NumC=parseInt(NumA/NumB); else NumC=parseInt(NumA/NumB)+1; return NumC; }; this.InitPageClass=function() { this.PCount=this.getDInt(this.PageCount,this.PSize); }; this.getLastPNum=function() { return (this.PCurrent-1)*this.PSize; }; this.getPNumAry=function() { this.PNumAry=new Array(this.PSize); var LPN=this.getLastPNum(); var PSi=0; for(var i=(LPN+1);i<=(LPN+this.PSize);i++) { if(PSi<this.PSize) { if(i<=this.PageCount) { this.PNumAry[PSi]=i; } else this.PNumAry[PSi]=-1; PSi++; } } }; } var PGCls=new PagesClass(); var ShowDiv=document.geElementById("Show_Div"); PGCls.PageCount=DataArray.length; PGCls.PSize=5;//按照每行5个图片的方法分页 PGCls.InitPageClass(); var reHtml=""; for(var r=0;r<PGCls.PCount;r++) { PGCls.PCurrent=r; PGCls.getPNumAry(); reHtml+="<table width=163 border=0 cellpadding=0 cellspacing=0 >"; reHtml+="<tr>"; for(var c=0;c<PGCls.PNumAry;c++) { reHtml+="<td width=71 height=70 valign=top >" reHtml+="<table width=71 border=0 cellpadding=0 cellspacing=0 >"; reHtml+="<tr>"; reHtml+="<td width=71 height=57 valign=middle >"; reHtml+="<div align=center >"; reHtml+="<img name=Icon src="+DataArray[PGCls.PNumAry][0]+" border=0 width=48 height=49 >"; reHtml+="</div>"; reHtml+="</td>"; reHtml+="</tr>"; reHtml+="<tr>"; reHtml+="<td height=13 valign=top >"; reHtml+="<div align=center >"; reHtml+="<FONT size=3 face=仿宋_GB2312 >"; reHtml+=DataArray[PGCls.PNumAry][1]; reHtml+="</FONT>"; reHtml+="</div>"; reHtml+="</td>"; reHtml+="<tr>"; reHtml+="</table>"; reHtml+="<td width=12 > </td>"; } reHtml+="</tr>"; reHtml+="</table>"; } ShowDiv.innerHTML=reHtml; |
FSO读取文件夹里所有图片,然后按照横5竖3的方式排列,并且分页,程序我已经写好了,问题在按照横5竖3排列就比较难了,对FSO比较熟悉的兄弟帮我修改一下这个程序
<table width="100%" border="1" cellpadding="0" style="border-collapse:collapse" cellspacing="0" bordercolor="#D4D0C8">
<tr height="18" align="center" bgcolor="#19A1DD" style="color:#fff;">
<td colspan="5">我的相册</td>
</tr>
<tr bgcolor="#f9f9f9" align="center">
<%
Page=Request.QueryString("Page")
if Page="" then Page=1 else Page=cint(Page) end if
PatentFolder = "pic/2007联欢会/" '图片文件夹
FoldPage = 15
Set Fso = CreateObject("Scripting.FileSystemObject")
if Fso.FolderExists(Server.Mappath(PatentFolder)) then
Set FolderCount = Fso.GetFolder(Server.Mappath(PatentFolder)).files
For Each F1 in FolderCount
if (Page-1)*FoldPage<=i and i<(Page-1)*FoldPage+FoldPage then '循环部分
%>
<td height="170">
<img src="<%=PatentFolder&F1.Name%>" style="width:150px; height:119px;" /><br>
<%=F1.DateLastAccessed%><br>
<input type="button" value="删除" style="cursor:pointer; width:30px; height:16px;" />
</td>
<%
end if
i=i+1
next
ThePageCount = Sgn(FolderCount.Count/FoldPage)+fix(FolderCount.Count/FoldPage)-1 '总页数
TheFileCount = FolderCount.Count '总记录数
Set FolderCount = Nothing
Set Fso = Nothing
%>
</tr>
<tr align="center" bgcolor="#e7e7e7" height="20">
<td colspan="15">
<%
Response.Write "共<b>"&TheFileCount&"</b>张 共<b>"&ThepageCount&"</b>页 当前第<b>"&page&"</b>页 "
Response.Write "<a href=?page=1>首页</a> "
IF page>1 Then
Response.Write "<a href=?page="&page-1&">上一页</a> "
Else
Response.Write "上一页 "
End IF
IF page<ThepageCount Then
Response.Write "<a href=?page="&page+1&">下一页</a> "
Else
Response.Write "下一页 "
End IF
Response.Write "<a href=?page="&ThepageCount&">尾页</a> "
Else
Response.write "无指定目录"
End IF
%>
</td>
</tr>
</table>