<script language = "JavaScript">
var aaa;
aaa=0;
bb = new Array();
<%count = 0 '定义bb数组下标变量
do while not rs.eof%>//循环所有记录
bb[<%=count%>] = new Array("<%= trim(rs("xiaoleiname"))%>","<%= trim(rs("daleiname"))%>","<%= trim(rs("xiaoleiid"))%>");//将(小类名,大类名,小类id)作为一个数据存入bb动态数组,bb变为一个二维数组
<%count = count + 1'下标变量递增
rs.movenext'移到下一条数据库记录
loop'循环
rs.close'关闭查询
set rs=nothing%>//释放变量
aaa=<%=count%>;传递动态数组最大下标
function chang1(dalei)//根据大类名改变小类下拉内容的函数
{
document.form1.xiaolei.length = 0; //清空小类下拉框内容
document.form1.xiaolei.disabled=false;//设置小类下拉框失效
var dalei=dalei;//这句个人认为没什么必要
var i;//定义循环用的下标变量
document.form1.xiaolei.options[0] = new Option('====行业名称====','');//给小类下拉框添加一个名称为“====行业名称====”的选项
for (i=0;i < aaa; i++)//开始循环
{
if (bb[i][1] == dalei)//根据大类名进行筛选
{
document.form1.xiaolei.options[document.form1.xiaolei.length] = new Option(bb[i][0], bb[i][0]);添加小类下拉框选项
}
}
if(document.form1.xiaolei.options.length==1)document.form1.xiaolei.disabled=true; //如果小类下拉框有选项,则恢复小类下拉框有效
}
</script>
<body>
<form name="form1" action="search_save.asp" method="post">
<select name="dalei" id="dalei" onChange="chang1(this.value)">">
<option value="">请选择行业范围</option>
<%sql="select * from hangyedalei"
set rs=server.createobject("ADODB.Recordset")
rs.open sql,conn,1,1
do while not rs.eof%>
<option value="<%=rs("daleiname")%>"><%=rs("daleiname")%></option>
<%rs.movenext
loop
rs.Close
set rs=nothing%>
</select>
<select name="xiaolei">
<option value="">请选择行业名称</option>
</select>