这是我在网上找到的代码,我是把它直接粘贴到asp里面的。但是他显示的就是空白的,什么都没有。本人是超菜新人,请大大们帮帮我,如何改才能实现幻灯片调用数据库。最好是解释一下,如:那个地方是在调用数据库、调用的数据库名称、图片的字段等(这些应该是用什么,是我自己服务器上的数据库里的,还是重写数据库)。<Script Language="JavaScript">
<!--
function SlidePic(ID) {this.ID=ID; this.Width=0;this.Height=0; this.TimeOut=5000; this.Effect=23; this.TitleLen=0; this.PicNum=-1; this.Img=null; this.Url=null; this.Title=null; this.AllPic=new Array(); this.Add=AddSlidePic; this.Show=ShowSlidePic; this.LoopShow=LoopShowSlidePic;}
function NewSlide() {this.ImgUrl=""; this.LinkUrl=""; this.Title="";}
function AddSlidePic(SP) {this.AllPic[this.AllPic.length] = SP;}
function ShowSlidePic() {
if(this.AllPic[0] == null) return false;
document.write('<div align="center"><a id="Url' + this.ID + '" href=""   target=_blank><img id="Img' + this.ID + '" style="width:' + this.Width + '; height:' + this.Height + '; filter: revealTrans(duration=2,transition=23);" src="javascript:null" border="0"></a>');
if(this.TitleLen != 0) document.write("<br><Div id='Title" + this.ID + "'></Div></div>");
this.Img = document.getElementById("Img" + this.ID);
this.Url = document.getElementById("Url" + this.ID);
this.Title = document.getElementById("Title" + this.ID);
this.LoopShow();
}
function LoopShowSlidePic() {
if(this.PicNum<this.AllPic.length-1) this.PicNum++ ;
else this.PicNum=0;
this.Img.filters.revealTrans.Transition=this.Effect;
this.Img.filters.revealTrans.apply();
this.Img.src=this.AllPic[this.PicNum].ImgUrl;
this.Img.filters.revealTrans.play();
this.Url.href=this.AllPic[this.PicNum].LinkUrl;
if(this.Title) this.Title.innerHTML='<a href="'+this.AllPic[this.PicNum].LinkUrl+'" >'+this.AllPic[this.PicNum].Title+'</a>';
this.Img.timer=setTimeout(this.ID+".LoopShow()",this.TimeOut);
}
var SlidePic = new SlidePic("SlidePic");
SlidePic.Width     = 150; //图片宽度
SlidePic.Height    = 120;   //图片高度
SlidePic.TimeOut   = 5000;   //延迟时间
SlidePic.Effect    = 23;
SlidePic.TitleLen = 1;
<% 
'幻灯片新闻
sql="select top 3 * from picnews order by id desc"   //数据库字段
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
k=1
Num_total=rs.recordcount
for i=1 to Num_total
%>
var NewItem = new NewSlide();
NewItem.ImgUrl = '<%=rs("News_pic")%>';   //图片地址
NewItem.LinkUrl= '<%=rs("News_url")%>';   //链接地址
NewItem.Title = '<span><%=rs("title")%></span>';   //新闻标题
SlidePic.Add(NewItem);
<%
rs.movenext
k=k+1
'loop
next
else
response.write "暂无图片新闻"
end if
%>
SlidePic.Show();
//-->
</Script>

解决方案 »

  1.   

    话说csdn 有个功能是添加代码 
      

  2.   

    http://hi.baidu.com/ilkikyo/blog/item/1b3994d7f50e6ddea144df57.html
    试试这个~~
      

  3.   

    我想要的是可以直接重数据库调用图片、文字、连接的效果。当然还是要感谢Lovely_baby的回帖。
    mjay0210大大请原谅,我可以说是不懂网站代码的,所以写的不正规、不好。我就是想要一个可实现在首页显示的、幻灯片形式的(我也不知道这个叫什么),要能直接重数据库里调用的。