JavaScript如何从数据库中提取数组?谁能帮忙写出asp完整代码?
实现效果是<scripttype="text/JavaScript">m="孙权,关羽,曹操,诸葛亮,周瑜,司马懿";</script>其中孙权,关羽,曹操,诸葛亮,周瑜...
实现效果是
<script type="text/JavaScript">
m = "孙权,关羽,曹操,诸葛亮,周瑜,司马懿";
</script>
其中孙权,关羽,曹操,诸葛亮,周瑜,司马懿是从数据库data.mdb的表user中的字段name中循环取出所有的姓名(随新用户注册加入,姓名会有添加或减少) 展开
<script type="text/JavaScript">
m = "孙权,关羽,曹操,诸葛亮,周瑜,司马懿";
</script>
其中孙权,关羽,曹操,诸葛亮,周瑜,司马懿是从数据库data.mdb的表user中的字段name中循环取出所有的姓名(随新用户注册加入,姓名会有添加或减少) 展开
2个回答
展开全部
<%
dim conn
dim rs,sql
dim users
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data.mdb")
Set rs = Server.Createobject("ADODB.Recordset")
sql="Select * from [user]"
rs.open sql,conn,1,1
do while not rs.eof
users = users & "," & rs("name")
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
if users<>"" then users=mid(users,2)
%>
<script type="text/JavaScript">
m = "<%=users%>";
</script>
dim conn
dim rs,sql
dim users
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data.mdb")
Set rs = Server.Createobject("ADODB.Recordset")
sql="Select * from [user]"
rs.open sql,conn,1,1
do while not rs.eof
users = users & "," & rs("name")
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
if users<>"" then users=mid(users,2)
%>
<script type="text/JavaScript">
m = "<%=users%>";
</script>
更多追问追答
追问
谢谢您的回答。我参考你提供的源码修改“抽奖系统 js压缩优化版V1.2.2”没有成功,不知您能否提供帮助
users = users & "," &"'"& rs("name")&"'"
var m_name = [""];
原为:var m_name = ["孙权","关羽","曹操","诸葛亮","周瑜","司马懿","杨志","鲁智深","孙尚香"];
抽奖系统http://www.thsg.cn/01/
追答
说一下具体情况吧,执行后得到什么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询