<!--#include file="include/conn.asp"-->
<title>菜单连动类的设计</title>
<%
'生成部门与人员列表数组
Response.Write("<script language='javascript'>"&vbcrlf)
Response.Write("var partarray=new Array();"&vbcrlf)
Response.Write("var userarray=new Array();"&vbcrlf)
partsql="select depart_id,depart_name from depart where company_id=1"
set partrs=server.CreateObject("ADODB.RecordSet")
partrs.Open partsql,conn,1,3
partcount=0
if not partrs.EOF and not partrs.BOF then
do while not partrs.EOF and not partrs.BOF
Response.Write("partarray["&partcount&"]='"&partrs("depart_id")&","&partrs("depart_name")&"';"&vbcrlf)
partrs.movenext
partcount=partcount+1
loop
end if
partrs.Close
set partrs=nothing
usersql="select employee_id,employee_name,employee_depart from employee where employee_status=1 and employee_company=1"
set userrs=server.CreateObject("ADODB.RecordSet")
userrs.Open usersql,conn,1,3
usercount=0
if not userrs.EOF and not userrs.BOF then
do while not userrs.EOF and not userrs.BOF
Response.Write("userarray["&usercount&"]='"&userrs("employee_id")&","&userrs("employee_name")&","&userrs("employee_depart")&"';"&vbcrlf)
userrs.MoveNext
usercount=usercount+1
loop
end if
//生成部门下拉菜单
function builddepart() {
document.form1.coursepart.length = 0;
var i;
for (i=0;i <partarray.length; i++) {
document.form1.coursepart.options[document.form1.coursepart.length] = new Option(partarray[i].split(",")[1],partarray[i].split(",")[0]);
}
}
//根据部门下拉菜单的值动态生成人员的值
function buildman(partid) {
document.form1.courseman.length=0;
var i;
for (i=0;i<userarray.length;i++) {
if (userarray[i].split(",")[2]==partid) {
document.form1.courseman.options[document.form1.courseman.length]=new Option(userarray[i].split(",")[1],userarray[i].split(",")[0]);
}
}
}
</script>
index.asp:如下
<script language="JavaScript">
function check() {
var url=form.xuehao.options[form.xuehao.selectedIndex].value;
navigate("index.asp.asp?xuehao="+url);
</script>
請選擇學號:
<form name=form>
<select name=xuehao onchange="check()">
<% do while not rs.eof%>
<option value="<%=rs("xuehao")%>"><%=rs("xuehao")%></option>
<%rs.movenext
loop%>
<%xuehao=request("xuehao")
if xuehao<>"" then
set rs1=server.createobject("adodb.recordset")
sql1="select name from table where xuehao="&xuehao '看著寫
rs1.open sql1,conn,1,1
if not rs.eof then
%>
姓名:<input type=text name=id value="<%=rs1("name")%>" readonly>
<% else%>
沒有這個學號的姓名!
<% end if
%>
function changelocation(locationid)
{
document.myform.Nclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}