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

请求大侠帮我分析一下:

<script language="javascript">
function check()
{
if( window.myform.reason.value==""){alert("please select reason");return false}
if( window.myform.ChannelId3.value==""){alert("please select item");return false}
}
var g_selProvince;
var g_selCity;
var g_selCounty;
file://一级目录
var Provinces=new Array();
<%
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from smallclass",conn,3,3
i=0
do while not rs1.eof
%>
Provinces[<%=i%>]=new Array("<%=rs1("smallclassid")%>","<%=trim(rs1("smallclassname"))%>");
<%rs1.movenext
i=i+1
loop%>

file://Array("与下级索引","显示的值")

file://二级目录
var Citys=new Array();
<%
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from product",conn,3,3
i=0
do while not rs2.eof
%>
Citys[<%=i%>]=new Array("<%=rs2("smallclassid")%>","<%=rs2("productid")%>","<%=trim(rs2("productname"))%>");

<%rs2.movenext
i=i+1
loop%>


file://Array("本级索引","与下级索引","显示的值")

file://三级目录
var Countys=new Array();
<%
set rs3=server.CreateObject("adodb.recordset")
rs3.open "select * from item",conn,3,3
i=0
do while not rs3.eof
%>
Countys[<%=i%>]=new Array("<%=rs3("productid")%>","<%=rs3("itemid")%>","<%=trim(rs3("ino"))%>/<%=trim(rs3("itemname"))%>"),


<%rs3.movenext
i=i+1
loop%>

file://Array("本级索引","与下级索引","显示的值")

function FillProvinces(selProvince)
{
selProvince.options[0]=new Option("select small class","");
for(i=0;i<Provinces.length;i++)
{
selProvince.options[i+1]=new Option(Provinces[i][1],Provinces[i][0]);
selProvince.options[0].selected=true;
}
selProvince.length=i+1;
}
function FillCitys(selCity,ProvinceCode)
{
selCity.options[0]=new Option("select product","");
count=1;
for(i=0;i<Citys.length;i++)
{
if(Citys[i][0].toString()==ProvinceCode)
{
selCity.options[count]=new Option(Citys[i][2],Citys[i][1]);
selCity.options[0].selected = true;
count=count+1;
}
}
selCity.length=count;
}
function FillCountys(selCounty,CityCode)
{
selCounty.options[0]=new Option("select item","");
count=1;
for(i=0;i<Countys.length;i++)
{
if(Countys[i][0]==CityCode)
{
selCounty.options[count]=new Option(Countys[i][2],Countys[i][1]);
selCounty.options[0].selected = true;
count=count+1;
}
}
selCounty.length=count;
}
function City_onchange()
{
FillCountys(g_selCounty,g_selCity.value);
}
function Province_onchange()
{
FillCitys(g_selCity,g_selProvince.value);
City_onchange();
}
function InitCitySelect(selProvince,selCity,selCounty)
{
g_selProvince=selProvince;
g_selCity=selCity;
g_selCounty=selCounty;
selProvince.onchange=Province_onchange;
selCity.onchange=City_onchange;
FillProvinces(selProvince);
Province_onchange();
}
</script>

搜索更多相关主题的帖子: 菜单 代码 
2006-03-11 14:29
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
http://bbs.bc-cn.net/bbs/dispbbs.asp?BoardID=10&ID=24520
那个对于初学者来说,个人认为复杂了一些,这个比较简单。
2006-03-11 15:13
快速回复:联动菜单代码分析
数据加载中...
 
   



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

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