下面这段调用数据库的代码写错了吗?怎么没有滚动效果,请高手帮看下:
do while not rs.eof
%>
<tr>
<td class="fonttd"><%=rs("dhsl_title")%></td>
</tr>
<%rs.MoveNext
Loop
rs.close
set rs=nothing
%>
下面这段调用数据库的代码写错了吗?怎么没有滚动效果,请高手帮看下:
do while not rs.eof
%>
<tr>
<td class="fonttd"><%=rs("dhsl_title")%></td>
</tr>
<%rs.MoveNext
Loop
rs.close
set rs=nothing
%>
这段代码是循环读取数据库内容,没有滚动控制的标签或代码,当然无法实现滚动效果的。
试试改一下这段代码。
<!--#include file="Include_conn.asp" -->
<%
set rs_expert=server.createobject("adodb.recordset")
sql="select top 6 * from expert where hot ='是' order by id desc"
rs_expert.open sql,conn,1,1
%>
<div id="demo" style="overflow:hidden;width:780px;height:150px">
<table cellpadding="0" cellspacing="0" border="0">
<tr><td id="demo1" valign="top" align="center">
<table cellpadding="2" cellspacing="0" border="0">
<tr align="center">
<%
if not rs_expert.eof then
do while not rs_expert.eof
%>
<td><a href="detail.asp?id=<%=rs_expert("id")%>&newstype=应用领域&data=expert" target="_blank"><img src="<%=rs_expert("pic")%>" width="167" height="130" border="0" /></a></td>
<%
rs_expert.movenext
loop
end if
%>
</tr>
</table>
</td>
<td id="demo2" valign="top"></td>
</tr>
</table>
</div>
<script>
var speed=2//速度数值越大速度越慢
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
<%
rs_expert.close
conn.close
%>