幻灯广告~~求解~~我不会JS读数据库
这是一个很多网站常用的JS滚动广告. 请问如果要动态的从数据库里面读取图片地址.URL链接和名称应该怎么写?
以下附代码
- JScript code
JScript code <!-- var focus_width=190 var focus_height=160 var text_height=20 var swf_height = focus_height+text_height var pics='js/images/1.jpg|js/images/2.jpg|js/images/3.jpg|js/images/4.jpg|js/images/5.jpg|js/images/6.jpg' var links='http://www.elandkey.com|http://www.elandkey.com|http://www.elandkey.com|http://www.elandkey.com|http://www.elandkey.com|http://www.elandkey.com' var texts='1|2|3|4|5|6' document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">'); document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="js/flash/cgal.swf"><param name="quality" value="high"><param name="bgcolor" value="#CCCCCC">'); document.write('<param name="menu" value="false"><param name=wmode value="opaque">'); document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">'); document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#ffffff" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>'); //-->// JavaScript Document这个是整个广告的源代码
请大家帮忙改下然后贴出来~
我不会用JS读数据库 ,有其他办法吗???
[解决办法]
<script type="text/javascript">
var pics=""
var links=""
var texts=""
<%
sql = "select top 5 * from aa"
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
dim i
dim picsStr,linksStr,textsStr
i = 1
do while not rs.eof
%>
pics=pics+"pic/ <%=rs("图片路径")%> "
links=links+escape(" <%=rs("连接路径")%> ")
texts=texts+" <%=rs("标题")%> "
<%
rs.movenext
i = i + 1
loop
end if
rs.close
%>
var focus_width=240
var focus_height=200
var text_height=18
var swf_height = focus_height+text_height
//var pics=imgUrl1+" ¦"+imgUrl2+" ¦"+imgUrl3+" ¦"+imgUrl4+" ¦"+imgUrl5
// var links=imgLink1+" ¦"+imgLink2+" ¦"+imgLink3+" ¦"+imgLink4+" ¦"+imgLink5
// var texts=imgtext1+" ¦"+imgtext2+" ¦"+imgtext3+" ¦"+imgtext4+" ¦"+imgtext5
document.write(' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'"> ');
document.write(' <param name="allowScriptAccess" value="sameDomain"> <param name="movie" value="images/focus1.swf"> <param name="quality" value="high"> <param name="bgcolor" value="#F0F0F0"> ');
document.write(' <param name="menu" value="false"> <param name=wmode value="opaque"> ');
document.write(' <param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"> ');
document.write(' </object> ');
</script>
[解决办法]
- HTML code
set rs......dim pic,txt,linkwhile not rs.eof pic=pic&rs("pic")&"|" txt=txt&rs("txt")&"|" link=link&"thread.asp?id="&rs("id")&"|"rs.movenextwendpic=left(pic,len(pic)-1)txt=left(txt,len(txt)-1)link=left(link,len(link)-1)%>....//js内容 var focus_width=190 var focus_height=160 var text_height=20 var swf_height = focus_height+text_heightvar link="<%=link %>";var txt="<%=txt %>";var pic="<%=pic %>";document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">'); document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="js/flash/cgal.swf"><param name="quality" value="high"><param name="bgcolor" value="#CCCCCC">'); document.write('<param name="menu" value="false"><param name=wmode value="opaque">'); document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">'); document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#ffffff" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
[解决办法]
这个源码网上到处都有下...包括ASP读取数据库里的图片的后台一起,,LZ如果难得找,给我点分,联系我QQ:309343825,我传给你
[解决办法]
最简单的:
用ASP读取数据库
把需要的字符串拼接起来
然后到js中处理
[解决办法]
<%
读出数据到变量
如A1,A2,A3
%>
var pics='<%=A1%>'
var links='<%=A2%>'
var texts='<%=A3%>'
OK了