Posted on 2009-06-11 14:01
飞思达工作室 阅读(206)
评论(0) 编辑 收藏
<%
db="db1.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
'如果你的服务器采用较老版本Access驱动,请用下面连接方法
'connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(db)
conn.Open connstr
%>
<html>
<body>
<form name="userset">
<!— group 的下拉列表-------------->
<select name="sltGroupID" onChange="change_select(document.userset.sltGroupID.options[this.selectedIndex].value)" size="1">
<option value="0" selected>用户组……</option>
<%
sql1="select * from rsGroup"
set rs1=conn.Execute(sql1)
rs1.MoveFirst
While Not rs1.EOF
%>
<option value="<%=rs1(0)%>"><%=rs1(1)%></option>
<%
rs1.MoveNext
Wend
%>
</select>
<!— user 的下拉列表-------------->
<select name="sltUserID" size="1">
<option value="0" selected>用户……</option>
</select>
</form>
<script language = "JavaScript">
//读入 rsUser的数据
arrSelect=new Array();
arrSelect[0] = new Array("用户……",0,0)
<%
sql2="select * from rsUser"
Set rs2= Server.CreateObject("ADODB.Recordset")
rs2.Open sql2,conn,3,2
rcount=rs2.RecordCount
%>
<%=rcount%>
<%
rs2.MoveFirst
for i=1 to rcount
%>
arrSelect[<%=i%>]=new Array("<%=rs2(2)%>","<%=rs2(1)%>","<%=rs2(0)%>");
<%
rs2.MoveNext
next
%>
//更新 user 下拉列表的函数
function change_select(selvalue)
{
document.userset.sltUserID.length=0;
var i;
for(i=0;i<arrSelect.length;i++)
{
if(arrSelect[i][1]==selvalue)
{
var newoption=new Option(arrSelect[i][0],arrSelect[i][2]);
document.userset.sltUserID.add(newoption);
}
}
} </script>
</body>
</html>