我从网上下的JS相册代码 它的图片是固定的直接把地址写在里面 
例如连续的几行:
<img src=固定的路径>;
<img src=.......>;
<img src=.......>;而我想连接数据库 点击播放后可以自动播放数据库中某一类型的全部图片
怎么写连接代码读图片路径啊
给个思路也行 或者指点一下

解决方案 »

  1.   

    载入页面的时候就要读取数据库把需要的图片地址都读取出来存入数组
    然后点播放就循环读取数组
    用setTimeout定时换图片即可
      

  2.   

    也可以用js+ajax读取数据库中的图片路径信息,保存到数组变量中
      

  3.   

    可以在数据库存图片的地址,然后读取数据库里面的地址给变量,把变量赋值给图片的src
      

  4.   


    <script type="text/javascript">
            var image = ['','','',''];//图片路径
             int count = 0;
            window.onload = function(){
                document.all.imagsId.src = image[count];
               document.all.imagsId.display = "block";
               count++;
               if (count >= image.lenght) {
                   count = 0;
               }
           }</script>
    <img src="" id="imagsId">
      

  5.   

    图片肯定是存的地址 现在图片都有了 也都存了 显示是用DATALIST绑定分页的 就是想点击一个自动播放按钮开始自动播放
    请教LONGLY:如何把需要的图片地址都读取出来存入数组?写一句关键的格式吧请教xk1126:能发一份详细的代码让我研究一下否 小弟先谢谢了 [email protected]
      

  6.   

    <div style="display:none" id="images1">
         <img src = "img2/P1.jpg"  id = "tree1"  name="tree1" width=749px height=226px>
         <img src = "img2/P2.jpg"  id = "tree2"  name="tree2" width=749px height=226px>
         <img src = "img2/P3.jpg"  id = "tree3"  name="tree3" width=749px height=226px>
         <img src = "img2/P4.jpg"  id = "tree4"  name="tree4" width=749px height=226px>
         <img src = "img2/P5.jpg"  id = "tree5"  name="tree5" width=749px height=226px>
         <img src = "img2/P6.jpg"  id = "tree6"  name="tree6" width=749px height=226px>
         <img src = "img2/P7.jpg"  id = "tree7"  name="tree7" width=749px height=226px>
         <img src = "img2/P8.jpg"  id = "tree8"  name="tree8" width=749px height=226px>
    </div>
    <tr>
        <td align="left"><table width="947"  border="0" cellspacing="0" cellpadding="0" >
            <tr>
                <td style="border: 1px solid #f7bc96;margin-bottom:0px;padding-bottom:0px" height="226px">
                    <!--
                    <img src="img/banner.gif" border="0"/>
                    -->
                    <img src="img2/P3.jpg" id ="the_pic" width="749px" height="226px" border="0"/>
                    </td>
                   
                  
                <td style="border: 1px solid #f7bc96;"><SCRIPT language=javascript>frist("swf/jft-512.swf", "196px", "226px");</SCRIPT></td>
               
            </tr>
        </table></td>
    </tr>
    <tr>
        <td height="10">&nbsp;</td>
    </tr>
    <script language="javascript">
         var pic=new Array();
    // var num=0;
        var xxa=0;
                setinter();
                function setinter(){
                    setInterval('show_pic()',3000); //Run();
             }
         function show_pic(){ //var pic_src=new Array();
    var PnoPic = document.getElementById("images1").getElementsByTagName("img");
                
    //var num1 = document.getElementById("num1").value;
    if(document.all){
    tran=Math.floor(Math.random()*23)+1;
    //alert(tran);
                document.getElementById("the_pic").style.filter="revealtrans(dulation=2,transition="+tran+")";
     document.getElementById("the_pic").filters.revealtrans.Apply();
    }
               
                     document.getElementById("the_pic").src=PnoPic[xxa].src;
                  xxa = xxa+1;
                  if(xxa>PnoPic.length-1){
                      xxa = 0;
                  }
                     if(document.all){
        document.getElementById("the_pic").filters.revealtrans.Play();}
              

               

    }</script>
      

  7.   

    你只要setTimeOut, 
    然后更换IMG的src属性就可以了。
      

  8.   

    循环的问题。你可以在服务器端做个next方法, 比如当前是第八张, 调用next方法, 返回第九个。然后你在客户端把当前的图片传过去问服务器下一个是什么就行了。