以下代码不知哪里有错误,请帮忙找错!!
<% dim conn,dbuid,dbpwd,dBName,dbip,rs,database database=1 dbuid="sa" '数据库登陆名 dbpwd="password" '数据库密码 dBName="dw" '数据库名称 dbip="(local)" '数据库所在地址,如果是本地数据库则为:(local) set conn=Server.CreateObject("adodb.Connection") Conn.Open "PROVIDER=SQLOLEDB.1;Data Source="&dbip&";Initial Catalog="&dBName&";Persist Security Info=True;User ID="&dbuid&";Password="&dbpwd&";Connect Timeout=30" set rs=server.CreateObject("ADODB.recordset") %> <head> <title>三级下拉选择</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT LANGUAGE="JAVASCRIPT"> <!-- // 单位数组。 var arrUnit = new Array(); <% Dim iii iii=0 rs.Open "select * from dw_b order by unit_id",conn,1,1 do while not rs.EOF Response.Write "arrUnit["+CSTR(iii)+"]= new Array(0,"+CSTR(rs("unit_id"))+",'"+rs("unit_name")+"');"+vbNewLine rs.MoveNext iii=iii+1 loop rs.Close %> // 部门数组。 var arrDept = new Array(); <% iii=0 rs.Open "select * from bm_b order by dept_id",conn,1,1 do while not rs.EOF Response.Write "arrDept["+CSTR(iii)+"]= new Array("+CSTR(rs("unit_id"))+","+CSTR(rs("dept_id"))+",'"+rs("dept_name")+"');"+vbNewLine rs.MoveNext iii=iii+1 loop rs.Close %> // 人员数组 var arrEmp = new Array(); <% iii=0 rs.Open "select * from yg_b order by emp_id",conn,1,1 do while not rs.EOF Response.Write "arrEmp["+CSTR(iii)+"]= new Array("+CSTR(rs("dept_id"))+","+CSTR(rs("emp_id"))+",'"+rs("emp_name")+"');"+vbNewLine rs.MoveNext iii=iii+1 loop rs.Close %>
function body_onload(){ var TD = GetParent(document.all("s0"), "TD"); TD.innerHTML = MakeMenu(arrUnit, 0, 0,"","s0", 1);
TD = GetParent(document.all("s1"), "TD"); TD.innerHTML = MakeMenu(arrDept, GetSelectvalue(document.all("s0")), 0,"","s1", 1);
TD = GetParent(document.all("s2"), "TD"); TD.innerHTML = MakeMenu(arrEmp, GetSelectvalue(document.all("s1")), 0,"","s2", 1); }
function GetParent(src, tag) { if (src && src.tagName!=tag){ return(GetParent(src.parentElement, tag)); } return src; }
function MakeMenu(arrSub, pValue, cValue, cText, name, bulSkip) { var sHTML = "<select name='" + name + "' onchange='JavaScript:SetSubMenu(this)' >"; if(bulSkip) sHTML += "<option value=0><未选择></option>"; for (var i=0; i < arrSub.length; i++){ if (arrSub[i][0]==pValue){ var tag = (arrSub[i][1]==cValue||arrSub[i][2]==cText)?" selected>":">"; sHTML += "<option value='" + arrSub[i][1] + "'" + tag + arrSub[i][2] + "</option>"; } } sHTML += "</select>"; return sHTML; }
function GetSelectValue(oSelect) { if (oSelect.selectedIndex < 0) return 0; return oSelect.options(oSelect.selectedIndex).value; }
function SetSubMenu(pSelect){ var oOption, svalue; if (pSelect.selectedIndex < 0) return; switch (pSelect.name){ case "s0": var TD = GetParent(document.all("s1"), "TD"); TD.innerHTML = MakeMenu(arrDept, GetSelectvalue("s0"), 0,"","s1", 0); TD = GetParent(document.all("s2"), "TD"); TD.innerHTML = MakeMenu(arrEmp, GetSelectvalue("s1"), 0,"","s2", 0); break; case "s1": var TD = GetParent(document.all("s2"), "TD"); TD.innerHTML = MakeMenu(arrEmp, GetSelectvalue("s1"), 0,"","s2", 0); break; default: } } --> </SCRIPT>
</head>
<body onLoad="body_onload()"> <TD> <SELECT NAME="s0" ONCHANGE="SetSubmenu(this)"></SELECT> </TD> <TD> <SELECT NAME="s1" ONCHANGE="SetSubmenu(this)"></SELECT> </TD> <TD> <SELECT NAME="s2" ONCHANGE="SetSubmenu(this)"></SELECT> </TD>
</body>
[此贴子已经被作者于2004-07-31 10:06:01编辑过]