二级联动菜单数据库版
2004-11-11 10:51
441 查看
<form action="" method="post" name="form1" id="form1">
<%
Dim rdsClass
Dim sqlClass
Dim rdsChlCls
Dim sqlChlCls
set rdsClass = Server.CreateObject("ADODB.Recordset")
sqlClass = "select * from big_class Where State = 1 Order By ListNum"
rdsClass.Open sqlClass,Conn,1,1
response.write "<script language=""JavaScript"">"
'var x_array = new Array(初始化列表);
s = "var p_array = new Array(" + cstr(rdsClass.recordcount-1) + ");"
response.write s
s = "var p_array_id = new Array(" + cstr(rdsClass.recordcount-1) + ");"
response.write s
i = 0
while not rdsClass.eof
set rdsChlCls = Server.CreateObject("ADODB.Recordset")
sqlChlCls = "select * from Dat_class where RootID="&rdsClass("RootId")
rdsChlCls.Open sqlChlCls,Conn,1,1
if rdsChlCls.recordcount > 0 then
s = "var p"+cstr(rdsClass("RootId"))+"_array = Array("
s1 = "var p"+cstr(rdsClass("RootId"))+"_array_id = Array("
while not rdsChlCls.eof
if trim(rdsChlCls("CnName"))<>"" then
a = rdsChlCls("CnName")
s = s + """" + rdsChlCls("CnName") + """"
s1 = s1 + """" + cstr(rdsChlCls("ClsId")) + """"
end if
rdsChlCls.movenext
if not rdsChlCls.eof then
if trim(rdsChlCls("CnName"))<>"" then
s = s + ","
s1 = s1 + ","
end if
end if
wend
s = s+ ");"
s1 = s1+ ");"
response.write s
response.write s1
response.write "p_array["+cstr(i)+"] = p"+cstr(rdsClass("RootId"))+"_array;"
response.write "p_array_id["+cstr(i)+"] = p"+cstr(rdsClass("RootId"))+"_array_id;"
end if
i = i + 1
rdsClass.movenext
wend
response.write "</script>"
%>
<script language="JavaScript">
<!--
function setSort(s1,s2)
{
param=s1.selectedIndex-1;
if(param>=0)
{
s2.options.length=0;
for(i=0;i<p_array[param].length;i++)
{
s2.options.length++;
s2.options[i].text=p_array[param][i];
s2.options[i].value=p_array_id[param][i];
}
}else
{
s2.options.length=0;
s2.options.length++;
s2.options[0].text="请选择";
s2.options[0].value="";
}
}
//-->
</script>
<select name="s1" onChange="setSort(this,this.form.s2);">
<option value="0" selected>--大类--</option>
<%
set rdsClass = Server.CreateObject("ADODB.Recordset")
sqlClass = "select * from big_class where State=1 order by listnum"
rdsClass.Open sqlClass,Conn,1,1
while not rdsClass.eof
%>
<option value="<%=rdsClass("RootId")%>"><%=rdsClass("CnName")%></option>
<%
rdsClass.movenext
wend
rdsClass.close
set rdsClass=nothing
%>
</select>
<select name="s2">
<option value="0" selected>--小类--</option>
</select>
<form>
<%
Dim rdsClass
Dim sqlClass
Dim rdsChlCls
Dim sqlChlCls
set rdsClass = Server.CreateObject("ADODB.Recordset")
sqlClass = "select * from big_class Where State = 1 Order By ListNum"
rdsClass.Open sqlClass,Conn,1,1
response.write "<script language=""JavaScript"">"
'var x_array = new Array(初始化列表);
s = "var p_array = new Array(" + cstr(rdsClass.recordcount-1) + ");"
response.write s
s = "var p_array_id = new Array(" + cstr(rdsClass.recordcount-1) + ");"
response.write s
i = 0
while not rdsClass.eof
set rdsChlCls = Server.CreateObject("ADODB.Recordset")
sqlChlCls = "select * from Dat_class where RootID="&rdsClass("RootId")
rdsChlCls.Open sqlChlCls,Conn,1,1
if rdsChlCls.recordcount > 0 then
s = "var p"+cstr(rdsClass("RootId"))+"_array = Array("
s1 = "var p"+cstr(rdsClass("RootId"))+"_array_id = Array("
while not rdsChlCls.eof
if trim(rdsChlCls("CnName"))<>"" then
a = rdsChlCls("CnName")
s = s + """" + rdsChlCls("CnName") + """"
s1 = s1 + """" + cstr(rdsChlCls("ClsId")) + """"
end if
rdsChlCls.movenext
if not rdsChlCls.eof then
if trim(rdsChlCls("CnName"))<>"" then
s = s + ","
s1 = s1 + ","
end if
end if
wend
s = s+ ");"
s1 = s1+ ");"
response.write s
response.write s1
response.write "p_array["+cstr(i)+"] = p"+cstr(rdsClass("RootId"))+"_array;"
response.write "p_array_id["+cstr(i)+"] = p"+cstr(rdsClass("RootId"))+"_array_id;"
end if
i = i + 1
rdsClass.movenext
wend
response.write "</script>"
%>
<script language="JavaScript">
<!--
function setSort(s1,s2)
{
param=s1.selectedIndex-1;
if(param>=0)
{
s2.options.length=0;
for(i=0;i<p_array[param].length;i++)
{
s2.options.length++;
s2.options[i].text=p_array[param][i];
s2.options[i].value=p_array_id[param][i];
}
}else
{
s2.options.length=0;
s2.options.length++;
s2.options[0].text="请选择";
s2.options[0].value="";
}
}
//-->
</script>
<select name="s1" onChange="setSort(this,this.form.s2);">
<option value="0" selected>--大类--</option>
<%
set rdsClass = Server.CreateObject("ADODB.Recordset")
sqlClass = "select * from big_class where State=1 order by listnum"
rdsClass.Open sqlClass,Conn,1,1
while not rdsClass.eof
%>
<option value="<%=rdsClass("RootId")%>"><%=rdsClass("CnName")%></option>
<%
rdsClass.movenext
wend
rdsClass.close
set rdsClass=nothing
%>
</select>
<select name="s2">
<option value="0" selected>--小类--</option>
</select>
<form>
相关文章推荐
- 小议sqlserver数据库主键选取策略
- JavaScript封装的常用工具类库bee.js用法详解【经典类库】
- 千年零一虫
- VC与Delphi之间动态链接库互相调用
- ATL实现Connection Point的一种简单的方法
- c#接简单数据库操作类
- javascript表单之间的数据传递!
- 在线等,一个十万火急的问题
- 独具量身定做特色的管理软件--数据大师
- delphi中的时间操作技术(1)
- delphi中的时间操作技术(2)
- VB五子棋问题,请高手赐教
- IP地址的隐藏(delphi实现 )
- DirectX.Capture
- 关于数据库备份的问题!
- 解析IP地址为主机域名
- 将某一主机域名解析为IP地址