这个程序能不能简化???

again_gyf 2004-11-28 12:31:37
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<%
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"

dim sql,rs,num,row

sql="select id,SiteName,SiteUrl,SiteIntro,LogoUrl from link order by ID Asc"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
%>
<%
if not rs.eof then
num=rs.RecordCount '记录总数
end if
If num Mod 3=0 Then
row=num/3
Else
row=Int(num/3)+1
End If
Response.Write(row)
%>
<%
dim id(100),SiteName(100),SiteUrl(100),SiteIntro(100),LogoUrl(100),Img(100),N,J

while not rs.eof
ID(n)=rs("ID")
SiteName(n)=rs("SiteName")
SiteUrl(n)=rs("SiteUrl")
SiteIntro(n)=rs("SiteIntro")
LogoUrl(n)=rs("LogoUrl")

n=n+1
rs.movenext
wend
rs.close
set rs=nothing
%>

<%
J=0
for i=0 to row-2
Img(i)="<table width=370 border=0 cellpadding=0 cellspacing=0><tr><td width=123 height=31 align=center><a href="&SiteUrl(j)&"><img src="&LogoUrl(j)&" border=0 width=88 height=31></a></td><td width=124 align=center><a href="&SiteUrl(j+1)&"><img src="&LogoUrl(j+1)&" border=0 width=88 height=31></a></td><td width=123 align=center><a href="&SiteUrl(j+2)&"><img src="&LogoUrl(j+2)&" border=0 width=88 height=31></a></td></tr></table>"
j=j+3


next
select case (num Mod 3)
case 0
Img(row-1)="<table width=370 border=0 cellpadding=0 cellspacing=0><tr><td width=123 height=31 align=center><a href="&SiteUrl(j)&"><img src="&LogoUrl(j)&" border=0 width=88 height=31></a></td><td width=124 align=center><a href="&SiteUrl(j+1)&"><img src="&LogoUrl(j+1)&" border=0 width=88 height=31></a></td><td width=123 align=center><a href="&SiteUrl(j+2)&"><img src="&LogoUrl(j+2)&" border=0 width=88 height=31></a></td></tr></table>"
case 1
Img(row-1)="<table width=370 border=0 cellpadding=0 cellspacing=0><tr><td width=123 height=31 align=center><a href="&SiteUrl(j)&"><img src="&LogoUrl(j)&" border=0 width=88 height=31></a></td><td width=124 align=center></td><td width=123 align=center></td></tr></table>"
case 2
Img(row-1)="<table width=370 border=0 cellpadding=0 cellspacing=0><tr><td width=123 height=31 align=center><a href="&SiteUrl(j)&"><img src="&LogoUrl(j)&" border=0 width=88 height=31></a></td><td width=124 align=center><a href="&SiteUrl(j+1)&"><img src="&LogoUrl(j+1)&" border=0 width=88 height=31></a></td><td width=123 align=center></td></tr></table>"
end select

%>
<base target="_blank">
<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<script language="JavaScript1.2">
<!--
/*设置下面的参数。 设置scrollerwidth和scrollerheight参数,设置成滚动显示的图片中尺寸最大的。*/
var scrollerwidth=370
var scrollerheight=35
var scrollerbgcolor='#f8f8f8'
//每个图间暂停3秒。
var pausebetweenimages=5000
//边界下面的行,如果希望logo都是带连接的,只要加上<a>标签即可。
var slideimages=new Array()// 内容
<%
for i=0 to row-1
Response.Write ("slideimages["&i&"]='"&img(i)&"'")
Response.Write vbcrlf
next
%>

//////以下不要修改////////////////
if (slideimages.length>1)
i=2
else
i=0
function move1(whichlayer){
tlayer=eval(whichlayer)
if (tlayer.top>0&&tlayer.top<=5){
tlayer.top=0
setTimeout("move1(tlayer)",pausebetweenimages)
setTimeout("move2(document.main.document.second)",pausebetweenimages)
return
}
if (tlayer.top>=tlayer.document.height*-1){
tlayer.top-=5
setTimeout("move1(tlayer)",100)
}
else{
tlayer.top=scrollerheight
tlayer.document.write(slideimages[i])
tlayer.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}}
function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.top>0&&tlayer2.top<=5){
tlayer2.top=0
setTimeout("move2(tlayer2)",pausebetweenimages)
setTimeout("move1(document.main.document.first)",pausebetweenimages)
return
}
if (tlayer2.top>=tlayer2.document.height*-1){
tlayer2.top-=5
setTimeout("move2(tlayer2)",100)
}
else{
tlayer2.top=scrollerheight
tlayer2.document.write(slideimages[i])
tlayer2.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}}
function move3(whichdiv){
tdiv=eval(whichdiv)
if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5){
tdiv.style.pixelTop=0
setTimeout("move3(tdiv)",pausebetweenimages)
setTimeout("move4(second2)",pausebetweenimages)
return
}
if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1){
tdiv.style.pixelTop-=5
setTimeout("move3(tdiv)",100)
}
else{
tdiv.style.pixelTop=scrollerheight
tdiv.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}
}
function move4(whichdiv){
tdiv2=eval(whichdiv)
if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5){
tdiv2.style.pixelTop=0
setTimeout("move4(tdiv2)",pausebetweenimages)
setTimeout("move3(first2)",pausebetweenimages)
return
}
if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1){
tdiv2.style.pixelTop-=5
setTimeout("move4(second2)",100)
}
else{
tdiv2.style.pixelTop=scrollerheight
tdiv2.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}}
function startscroll(){
if (document.all){
move3(first2)
second2.style.top=scrollerheight
}
else if (document.layers){
move1(document.main.document.first)
document.main.document.second.top=scrollerheight+5
document.main.document.second.visibility='show'
}}
window.onload=startscroll
//-->
</script> <ilayer id="main" width="&{scrollerwidth};" height="&{scrollerheight};" bgcolor="&{scrollerbgcolor};"> <layer id="first" left="0" top="1" width="&{scrollerwidth};"> <script
language="JavaScript1.2">
if (document.layers)
document.write(slideimages[0])
</script> </layer> <layer id="second" left="0" top="0" width="&{scrollerwidth};" visibility="hide"> <script language="JavaScript1.2">
if (document.layers)
document.write(slideimages[1])
</script> </layer> </ilayer> </p>
<p><script language="JavaScript1.2">
<!--
if (document.all){
document.writeln('<span id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hiden;background-color:'+scrollerbgcolor+'">')
document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0;top:0">')
document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0;top:1;">')
document.write(slideimages[0])
document.writeln('</div>')
document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0;top:0">')
document.write(slideimages[1])
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</span>')
}
//--></script>
</body>

这里数组的大小能否由数据库里有多少记录来定???
...全文
61 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
hj3793 2004-11-29
....晕...
回复
CnEve 2004-11-29
是很晕,我是懒人
回复
xxrl 2004-11-28
可以用多个文件来include,
回复
zhouyouok 2004-11-28
天啊,看晕了。
回复
在redim时用 Preserve 关键字可以保留数据原内容,redim后的数组比原数组小时,被排除的元素中的数据被丢弃。
回复
用动态数组:

dim array_test()
redim array_test(记录条数)
回复
again_gyf 2004-11-28
dim id(100),SiteName(100),SiteUrl(100),SiteIntro(100),LogoUrl(100),Img(100),N,J
这里数组的大小能否由数据库里有多少记录来定???
回复
liuyangxuan 2004-11-28
include
封装SUB OR FUNCTION
尽量重用。
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-11-28 12:31
社区公告
暂无公告