日期:2014-05-16  浏览次数:20456 次

如何在ASP中写JS代码来实现循环读取数据库?
源代码如下:

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/db.asp" -->

…………
Dim Rs5
Dim Rs5_numRows

Set 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”的静态图片变为数据库里的向下的读取记录)

------解决方案--------------------
http://topic.csdn.net/u/20090407/10/1057275c-fa93-4d30-9639-e1390d3a257e.html

看我在这个帖子里的回答