源代码如下:<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/db.asp" -->…………
Dim Rs5
Dim Rs5_numRowsSet Rs5 = Server.CreateObject("ADODB.Recordset")
Rs5.ActiveConnection = MM_db_STRING
Rs5.Source = "SELECT *  FROM news ORDER BY ID DESC"
Rs5.CursorType = 0
Rs5.CursorLocation = 2
Rs5.LockType = 1
Rs5.Open()
Rs5_numRows = 0
…………
    <script type="text/javascript">
                var focus_width=320;
                var focus_height=159;
                var text_height=20;
                var swf_height=focus_height + text_height;     var pics="manage<%=Rs5("pic_s")%>|index/images/02.jpg|index/images/03.jpg";

                var fo = new SWFObject("index/images/pix.swf", "_FocusObj", focus_width, swf_height, "7","F6F8FA");
     fo.addVariable("pics", pics);
     fo.addVariable("links", links);
     fo.addVariable("texts", texts); 
     fo.addVariable("borderwidth", focus_width);
     fo.addVariable("borderheight", focus_height);
     fo.addVariable("textheight", text_height);
     fo.addVariable("border_color", "0x000000"); 

     fo.addVariable("fontsize", "12"); 
     fo.addVariable("fontcolor", "5d5d5d");
     fo.addVariable("is_border", "");
     fo.addVariable("is_text", "1");
     fo.addParam("wmode", "opaque");
     fo.write("FocusObj");
              </script>
…………
小弟想实现动态调用数据库的图片记录,但是我只能用一次“<%=Rs5("pic")%>”,可以调用到数据库里的第一张图片,但是不能用"rs5.movenext"来实现循环。我想实现循环读取记录,并且可以控制读取多少条不知JS代码怎么写,或者ASP的代码怎么和JS代码结合。(例如:把最后的JS代码“02.jpg|03.jpg”的静态图片变为数据库里的向下的读取记录)

解决方案 »

  1.   

    http://topic.csdn.net/u/20090407/10/1057275c-fa93-4d30-9639-e1390d3a257e.html看我在这个帖子里的回答
      

  2.   

    刚才在ASP里怎么没有给到你分? 我在这里给你
      

  3.   

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <!--#include file="Connections/aspconn2.asp" -->
    <%
    Dim Recordset1
    Dim Recordset1_numRowsSet Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_aspconn2_STRING
    Recordset1.Source = "SELECT * FROM map ORDER BY id DESC"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 1
    Recordset1.Open()Recordset1_numRows = 0
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><style type="text/css">
    #container{width:646px;height:580px;}
    </style>
    <script charset="utf-8" src="http://api.map.soso.com/v1.0/main.js"></script>
    <script type="text/javascript">
    var map;
    function init(){
        var center=new soso.maps.LatLng(37.453968,116.307428);
        map=new soso.maps.Map(document.getElementById("container"),{
            center:center,
            zoomLevel:10
        })
        map.setScrollWheel(true);
        map.setKeyBoard(true);
        map.setDraggable(true);
        map.setZoomInByDblClick(true);
        var navControl = new soso.maps.NavigationControl({
            align: soso.maps.ALIGN.TOP_LEFT,
            style:soso.maps.NavigationControlStyle.DEFAULT,
            margin: new  soso.maps.Size(5, 15),
            map: map
        });
        var overviewControl = new soso.maps.OverviewMapControl({
            align: soso.maps.ALIGN.BOTTOM_RIGHT,
            map: map
        });    var zoomhintControl = new soso.maps.ZoomHintControl({map: map});
        var scaleControl = new soso.maps.ScaleControl({
            align: soso.maps.ALIGN.BOTTOM_LEFT,
            margin: new  soso.maps.Size(10, 15),
            map: map
        });    //创建er
        var erStack=[];
        var infoWin = new soso.maps.InfoWindow({
            map: map
        });<!--下面这段代码调用数据库的内容如何实现循环-->
        var anchor0= new soso.maps.Point(10, 30),
            size0 = new soso.maps.Size(20, 30),
            icon0= new soso.maps.MarkerImage(
                "http://api.map.soso.com/doc/tooles/../img/mar_img1.png",
                size0,
                anchor0),
            er0 = new soso.maps.Marker({
                icon: icon0,
                map:map,
                position:new soso.maps.LatLng(37.444156,116.311548)
            });
            er0.BZ="<%=(Recordset1.Fields.Item("name").Value)%>";
            er0.label = new soso.maps.Label({
                content:"<%=(Recordset1.Fields.Item("address").Value)%>",
                map:map
            });
        erStack.push(er0);
        soso.maps.Event.addListener(er0,"click",function(){
            infoWin.open(
                "<div style='width:237px;height:152px;'>"+
                    "<div style='color:red;'><%=(Recordset1.Fields.Item("address").Value)%></div>"+
                   "<div style='margin-top:10px;'>"+
                       "<div style='width:232px;"+
                       "height:100px;overflow:auto;border:1px solid #ddd;"+
                       "background:#fff;font-size:12px;'>"+
                       "<%=(Recordset1.Fields.Item("name").Value)%>"+
                       "</div>"+
                   "</div>"+
               "</div>",this);
        });
    <!--循环到这里,上面这段代码,怎样实现循环调用数据库信息,高手帮忙啊-->
        resetML(erStack)
        soso.maps.Event.addListener(map,"zoomlevel_changed",function(){
            resetML(erStack)
        });
        //重新设置labelk和er之间的距离
        function resetML(arr){
            if(arr.length!=0){
                each(arr,function(n){
                    var point=map.fromLatLngToContainerPixel(this.getPosition());
                    var pointN=new soso.maps.Point(point.getX()+12,point.getY()-10);
                    this.label.setPosition(map.fromContainerPixelToLatLng(pointN));
                 });
            }
        }
        //对数组进行遍历
        function each(arr,fn){
            for(var n=0;n<arr.length;n++){
                fn.call(arr[n],n);
            }
        }
        
        
        
    }
    window.onload=init;
    </script>
    <body>
    <div id="container"></div>
    </body>
    </html>
    <%
    Recordset1.Close()
    Set Recordset1 = Nothing
    %>