ASP三级联动下拉菜单选择只有一级的确显示第三级,求修改!!!
本帖最后由 miohofish 于 2013-06-03 11:29:28 编辑
比如我先选择了一个有第二级和第三级的选项后再选择一个只有一级的选项确第三级还是显示刚刚选择过得第三级,没有清空,请问怎么样清空,求添加代码?本人初学者
<!--#include file="conn.asp"-->
<%dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from [class_menu] order by class_order ASC",conn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%=trim(rs("class_name"))%>","<%= rs("id")%>","<%=rs("class_id_1")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.class2id.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][2] == locationid)
{
document.myform.class2id.options[document.myform.class2id.length] = new Option(subcat[i][0], subcat[i][1]);
changelocation2(document.myform.class2id.options[document.myform.class2id.selectedIndex].value)
}
}
}
function changelocation2(locationid)
{
document.myform.class3id.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][2] == locationid)
{
document.myform.class3id.options[document.myform.class3id.length] = new Option(subcat[i][0], subcat[i][1]);
}
}
}
</script>
<script language="JavaScript">
function CheckForm()
{
if(document.myform.class1id.value<=0) {
document.myform.class1id.focus();
alert("请选择市级分类!");
return false;
}