<!--#include virtual = "/inc/connection.inc"-->
<%
strSQL = "select company, unit_no, unit_cname from DepList order by company, unit_no"
call listmaker(strSQL, companylist, departmentlist , pubevent)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>大大集團</title>
</head>
<%
strSQL = "select company, unit_no, unit_cname from DepList order by company, unit_no"
call listmaker(strSQL, companylist, departmentlist , pubevent)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>大大集團</title>
</head>
<body>
<div align="center">
<form name="form1">
<table width="625" border="1" cellspacing="0" cellpadding="0">
<tr>
<td height="40" colspan="2" bgcolor="#006699"><div align="center"><font color="#FFFFFF" size="+1"><strong>搜 尋 條 件</strong></font></div></td>
</tr>
<tr>
<td width="30%" height="80" bgcolor="#006699"> <div align="center"><font color="#FFFFFF">公 司</font></div></td>
<td bgcolor="#CCFFFF"> <select name="company" class="select1" OnChange="Buildkey(this.selectedIndex);"><%= companylist%></select></td>
</tr>
<tr>
<td width="30%" height="80" bgcolor="#006699"> <div align="center"><font color="#FFFFFF">部 門</font></div></td>
<td bgcolor="#CCFFFF"> <select name="department" class="select1"><%= departmentlist%></select></td>
</tr>
</table>
</form>
<p> </p>
</div>
</body>
</html>
<SCRIPT Language="JavaScript">
<!--
<%=pubevent%>
function Buildkey(num)
{
document.form1.department.selectedIndex=0;
for(ctr=0;ctr<key[num].length;ctr++)
{
document.form1.department.options[ctr]=new Option(key[num][ctr],key[num][ctr]);
}
document.form1.department.length=key[num].length;
}
//-->
</Script>
<%
SUB listmaker(strSQL, byref list1, byref list2, byref myevent)
set rsCom = OBJConn.execute("SELECT Count(Com_ID) FROM ComList")
'howmanygroups 代表共有幾間公司
howmanygroups=rsCom(0)
set rsCom = nothing
'定義key的陣列大小
tempSTR1 = "key=new Array(" &howmanygroups & ");" &vbcrlf
set rs = OBJConn.execute(strSQL)
'利用 companylist 字串變數來建立第一個下拉式選單的 Html 原始碼。
companylist = ""
'利用 departmentlist 字串變數來建立第二個下拉式選單的 Html 原始碼。
departmentlist=""
'在這裡初始某些變數值,當作底下執行運算時之旗標值。
lastvalue=rs(0)
lastvalue2=rs(1)
lastvalue3=rs(2)
'thissubgroupcount 代表某間公司共有幾個部門
thissubgroupcount=0
'thisgroupcount 代表第幾間公司
thisgroupcount=0
DO while not rs.eof
thisvalue = rs(0)
thisvalue2 = rs(1)
thisvalue3 = rs(2)
'當第一筆資料時
if (thisgroupcount=0 and thissubgroupcount=0) then
companylist = companylist & "<option value='" & thisvalue & "'>" & thisvalue & "</option>" & vbcrlf
end if
'公司改變時
if (thisvalue<>lastvalue) then
tempSTR2 = tempSTR2 + "key[" & thisgroupcount & "]=new Array(" & thissubgroupcount & ");" & vbcrlf
companylist = companylist & "<option value=" & thisvalue & ">" & thisvalue & "</option>"
thisgroupcount = thisgroupcount+1
thissubgroupcount = 0
end if
'當部門改變時
if (thisvalue2<>lastvalue2) or (thisgroupcount=0 and thissubgroupcount=0) then
'是第一家公司時,秀出其部門
if (thisgroupcount=0) then
departmentlist = departmentlist + "<option value='" & thisvalue2 & "'>" & thisvalue3 & "</option>" & vbcrlf
end if
tempSTR = tempSTR + "key[" & thisgroupcount & "][" &thissubgroupcount & "]='" &thisvalue3 & "';" & vbcrlf
thissubgroupcount = thissubgroupcount+1
end if
lastvalue = thisvalue
lastvalue2 = thisvalue2
lastvalue3 = thisvalue3
rs.MoveNext
LOOP
'最後一個 key[第幾間公司] 和 key1[第幾間公司] 的陣列長度還未定義。
tempSTR1 = tempSTR1 + "key[" & thisgroupcount & "]=new Array(" & thissubgroupcount & ");" & vbcrlf
'大功告成,可以關閉資料庫了。
rs.close
set rs=nothing
OBJConn.close
set OBJConn=nothing
pubevent = tempSTR1 & tempSTR2 & tempSTR
END sub
%>
<div align="center">
<form name="form1">
<table width="625" border="1" cellspacing="0" cellpadding="0">
<tr>
<td height="40" colspan="2" bgcolor="#006699"><div align="center"><font color="#FFFFFF" size="+1"><strong>搜 尋 條 件</strong></font></div></td>
</tr>
<tr>
<td width="30%" height="80" bgcolor="#006699"> <div align="center"><font color="#FFFFFF">公 司</font></div></td>
<td bgcolor="#CCFFFF"> <select name="company" class="select1" OnChange="Buildkey(this.selectedIndex);"><%= companylist%></select></td>
</tr>
<tr>
<td width="30%" height="80" bgcolor="#006699"> <div align="center"><font color="#FFFFFF">部 門</font></div></td>
<td bgcolor="#CCFFFF"> <select name="department" class="select1"><%= departmentlist%></select></td>
</tr>
</table>
</form>
<p> </p>
</div>
</body>
</html>
<SCRIPT Language="JavaScript">
<!--
<%=pubevent%>
function Buildkey(num)
{
document.form1.department.selectedIndex=0;
for(ctr=0;ctr<key[num].length;ctr++)
{
document.form1.department.options[ctr]=new Option(key[num][ctr],key[num][ctr]);
}
document.form1.department.length=key[num].length;
}
//-->
</Script>
<%
SUB listmaker(strSQL, byref list1, byref list2, byref myevent)
set rsCom = OBJConn.execute("SELECT Count(Com_ID) FROM ComList")
'howmanygroups 代表共有幾間公司
howmanygroups=rsCom(0)
set rsCom = nothing
'定義key的陣列大小
tempSTR1 = "key=new Array(" &howmanygroups & ");" &vbcrlf
set rs = OBJConn.execute(strSQL)
'利用 companylist 字串變數來建立第一個下拉式選單的 Html 原始碼。
companylist = ""
'利用 departmentlist 字串變數來建立第二個下拉式選單的 Html 原始碼。
departmentlist=""
'在這裡初始某些變數值,當作底下執行運算時之旗標值。
lastvalue=rs(0)
lastvalue2=rs(1)
lastvalue3=rs(2)
'thissubgroupcount 代表某間公司共有幾個部門
thissubgroupcount=0
'thisgroupcount 代表第幾間公司
thisgroupcount=0
DO while not rs.eof
thisvalue = rs(0)
thisvalue2 = rs(1)
thisvalue3 = rs(2)
'當第一筆資料時
if (thisgroupcount=0 and thissubgroupcount=0) then
companylist = companylist & "<option value='" & thisvalue & "'>" & thisvalue & "</option>" & vbcrlf
end if
'公司改變時
if (thisvalue<>lastvalue) then
tempSTR2 = tempSTR2 + "key[" & thisgroupcount & "]=new Array(" & thissubgroupcount & ");" & vbcrlf
companylist = companylist & "<option value=" & thisvalue & ">" & thisvalue & "</option>"
thisgroupcount = thisgroupcount+1
thissubgroupcount = 0
end if
'當部門改變時
if (thisvalue2<>lastvalue2) or (thisgroupcount=0 and thissubgroupcount=0) then
'是第一家公司時,秀出其部門
if (thisgroupcount=0) then
departmentlist = departmentlist + "<option value='" & thisvalue2 & "'>" & thisvalue3 & "</option>" & vbcrlf
end if
tempSTR = tempSTR + "key[" & thisgroupcount & "][" &thissubgroupcount & "]='" &thisvalue3 & "';" & vbcrlf
thissubgroupcount = thissubgroupcount+1
end if
lastvalue = thisvalue
lastvalue2 = thisvalue2
lastvalue3 = thisvalue3
rs.MoveNext
LOOP
'最後一個 key[第幾間公司] 和 key1[第幾間公司] 的陣列長度還未定義。
tempSTR1 = tempSTR1 + "key[" & thisgroupcount & "]=new Array(" & thissubgroupcount & ");" & vbcrlf
'大功告成,可以關閉資料庫了。
rs.close
set rs=nothing
OBJConn.close
set OBJConn=nothing
pubevent = tempSTR1 & tempSTR2 & tempSTR
END sub
%>