日期:2014-05-16 浏览次数:20375 次
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JS动态列表示例</title>
<script language="JavaScript"><!--
<%
dim conn,rs,grs,i,j,pstr,sstr
set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
set grs=server.createobject("adodb.recordset")
'conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("dlist.mdb")
conn.open "DRIVER={SQL Server};SERVER=127.0.0.1;DATABASE=wzjs_mis;uid=wzjs;pwd=wzjs"
'写省份JS数组
rs.open "select * from province;",conn,1,1
pstr="var pstr=new Array("
for i=0 to rs.recordcount-1
if i<>rs.recordcount-1 then
pstr=pstr & "'" & rs("p_name") & "',"
else
pstr=pstr & "'" & rs("p_name") & "'"
end if
getsub(rs("p_name"))
rs.movenext
next
pstr=pstr & ");"
response.write pstr & vbcrlf
rs.close()
set rs=nothing
set grs=nothing
'根据省份写城市JS数组的过程
sub getsub(pname)
grs.open "select * from city where c_pid='" & pname & "';",conn,1,1
sstr="var sstr" & i & "=new Array("
for j=1 to grs.recordcount
if j<>grs.recordcount then
sstr=sstr & "'" & grs("c_name") & "',"
else
sstr=sstr & "'" & grs("c_name") & "'"