| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1882 人关注过本帖
标题:三级下拉选择原代码--问题出在哪?
只看楼主 加入收藏
xpx
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2004-7-3
收藏
 问题点数:0 回复次数:1 
三级下拉选择原代码--问题出在哪?

以下代码不知哪里有错误,请帮忙找错!!

<% 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编辑过]

搜索更多相关主题的帖子: 数据库 代码 dbuid 
2004-07-31 10:04
xpx
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2004-7-3
收藏
得分:0 

人气不望

2004-08-08 00:22
快速回复:三级下拉选择原代码--问题出在哪?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022298 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved