注册 登录
编程论坛 ASP技术论坛

我的一个小程序定时循环变换图片

ikonglin 发布于 2010-11-04 22:16, 406 次点击
<form method="post" action="" name="form1" id="form1">
<input type="text" name="t1" id="t1" />
<input type="hidden" name="hd1" id="hd1" />
</form>
<script language="javascript">
setTimeout("tj()",5000);
function tj(){
document.form1.submit();
}
</script>
<%
response.buffer=true
if request.Cookies("id")<>"" then
response.Cookies("id")=request.Cookies("id")+1
else
response.Cookies("id")=1
end if
%>
<p>
<!--#include file="conn/conn.asp"-->
<%
rs.open "select * from 职工信息",cn,1,1
%>
<p>
<%
if cint(request.Cookies("id"))>rs.recordcount then
response.Cookies("id")=1
end if
rs.close
sql="select * from 职工信息 where id=" & request.Cookies("id")
rs.open sql,cn,1,1
response.Write rs("照片")
%>
<p>
<img src=<%=rs("照片")%> />
<%
rs.close
%>
调试成功
4 回复
#2
cnfarer2010-11-05 07:59
很好.提高点难度:能一次交互实现吗?试试吧!
#3
ikonglin2010-11-05 14:02
一次页面交互只能用javascript了,我是新手,不知道在javascript脚本中能不能插入asp的代码
#4
ikonglin2010-11-05 14:04
为什么上面的代码在IE中正常显示,在360浏览器和糖果浏览器中不正常
#5
ikonglin2010-11-17 18:50
终于实现一次交互了。
<!--#include file="conn/conn.asp"-->
<%
rs.open "select * from 职工信息",cn,1,1
n=rs.recordcount
redim pt(n)
i=0
do while not rs.eof
pt(i)=rs("照片")
str=str+pt(i)& ","
i=i+1
rs.movenext
loop
%>
<img name="img1" id="img1" src="<%=pt(0)%>">
<script language="javascript">
str="<%=str%>";
tt=str.split(",");
var i=0
function xh(){
if(i<=tt.length-2)
{
    i=i+1;
}
if(i==tt.length-1)
{
    i=0;
}
document.img1.src=tt[i];
setTimeout("xh()",5000);
}

setTimeout("xh()",5000);
</script>
1