我想写段代码,JS的。
他里面要用到数组,请问
JS脚本里使用数组怎样调用ACCESS数据库的记录?
我从网上弄了一段图片自动切换的代码,可是不明白他是怎么调用ACCESS表里图片路径的。
<!-- 动态图开始 --> <script language=JavaScript>
var imgUrl=new Array(); var imgLink=new Array(); var adNum=0; imgUrl[1]="http://image2.sina.com.cn/ty/f1/U574P6T158D1F3398DT20040810112605.jpg"; imgLink[1]="http://sports.sina.com.cn/f1/2003f1/photo/4192/index.shtml"; imgUrl[2]="http://image2.sina.com.cn/ty/f1/U574P6T158D1F3449DT20040810112605.jpg"; imgLink[2]="http://sports.sina.com.cn/f1/2003f1/photo/4192/index.shtml"; imgUrl[3]="http://image2.sina.com.cn/ty/f1/U574P6T158D1F3451DT20040810112715.jpg"; imgLink[3]="http://sports.sina.com.cn/f1/2003f1/photo/4192/index.shtml"; imgUrl[4]="http://image2.sina.com.cn/ty/f1/U574P6T158D1F3453DT20040810112715.jpg"; imgLink[4]="http://sports.sina.com.cn/f1/2003f1/photo/4192/index.shtml"; imgUrl[5]="http://image2.sina.com.cn/ty/f1/U574P6T158D1F3455DT20040226120256.jpg"; imgLink[5]="http://f1.sina.com.cn/2004-07-27/16351027462.shtml";
var imgPre=new Array(); var j=0; for (i=1;i<=5;i++) { if( (imgUrl[i]!="") && (imgLink[i]!="") ) { j++; } else { break; } }
function playTran(){ if (document.all) imgInit.filters.revealTrans.play(); }
var key=0; function nextAd(){ if(adNum<j)adNum++ ; else adNum=1; if( key==0 ){ key=1; } else if (document.all){ imgInit.filters.revealTrans.Transition=6; imgInit.filters.revealTrans.apply(); playTran();
} document.images.imgInit.src=imgUrl[adNum]; theTimer=setTimeout("nextAd()", 6000); }
function goUrl(){ jumpUrl=imgLink[adNum]; jumpTarget='_blank'; if (jumpUrl != ''){ if (jumpTarget != '') window.open(jumpUrl,jumpTarget); else location.href=jumpUrl; } } </script> <a href="javascript:goUrl()"><img style="FILTER: revealTrans(duration=2,transition=20);border-color:white;color:#000000" src="javascript:nextAd()" width=258 height=162 border=1 class=img01 name=imgInit></a><!-- 动态图结束 -->
能告诉我,他是怎么取这些图片的路径又怎么赋给数组的吗?
救命啊!!!代码怎么还是有错误?还是报网页上有错误,无法显示。
<!--#include file="conn.asp"-->
<meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <% set rs=server.createobject("adodb.recordset") sql="select * from ptnews where news_pic<>''" rs.open conn,3,3 %> <script language=JavaScript> <!-- var bannerAD=new Array(); var bannerADlink=new Array(); var adNum=0; <% for i=0 to 3 %>
bannerAD[i]="<%=rs("news_pic")%>"; <%next%> var preloadedimages=new Array(); for (i=1;i<4;i++){ preloadedimages[i]=new Image(); preloadedimages[i].src=bannerAD[i]; }
function setTransition(){ if (document.all){ bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23); bannerADrotator.filters.revealTrans.apply(); } }
function playTransition(){ if (document.all) bannerADrotator.filters.revealTrans.play() }
function nextAd(){ if(adNum<bannerAD.length-1)adNum++ ; else adNum=0; setTransition(); document.images.bannerADrotator.src=bannerAD[adNum]; playTransition(); theTimer=setTimeout("nextAd()", 6000); }
function jump2url(){ jumpUrl=bannerADlink[adNum]; jumpTarget='_blank'; if (jumpUrl != ''){ if (jumpTarget != '')window.open(jumpUrl,jumpTarget); else location.href=jumpUrl; } } function displayStatusMsg() { status=bannerADlink[adNum]; document.returnValue = true; } //--> </script>
<table cellpadding=0 cellspacing=0 width=111> <tr> <td colspan=3 height=1 bgcolor=#ffffff> <img src=c.gif width=1 height=1></td> </tr> <tr> <td bgcolor=#ffffff width="2"><img src=c.gif width=1 height=1></td> <td width="109"><a href="javascript:jump2url(1)"><img style="FILTER: revealTrans(duration=2,transition=20)" height=100 src="javascript:nextAd()" width=100 border=0 name=bannerADrotator></a></td> </tr> <tr> <td colspan=3 height=1 bgcolor=#ffffff> <img src=c.gif width=1 height=1></td> </tr> </table> <% 'rs.movenext 'loop rs.close %>