关于无限分级(ASP+数据库+JS)的实现代码(2)
for(k=0;k<id.length;k++){
if(thevalue==id[k]){id_s+=thevalue+"|";cotename_s+=cotename[k]+"|";thevalue_r=byid[k];break;}else{thevalue_r=0;}
}
for(i=0;i<id.length;i++){
if(thevalue==byid[i]){
id_s+=id[i]+"|";cotename_s+=cotename[i]+"|";
}
}
if(id_s=='-1|'){
for(i=0;i<id.length;i++){
if(thevalue==id[i]){
id_s+=id[i]+"|";cotename_s+=cotename[i]+"|";
}
}
}
id_v=id_s.split("|");
cotename_v=cotename_s.split("|");
var length=id_v.length-1;
for(j=0;j<length;j++){
if(thevalue==id_v[j]){
data+="<option value='"+id_v[j]+"' selected>"+cotename_v[j]+"</option>";}
else{
data+="<option value='"+id_v[j]+"'>"+cotename_v[j]+"</option>";
}
}
if(thevalue!=0){data+="<option value='"+thevalue_r+"'>上级分类</option>";}
//alert(length+'/'+thevalue);
var lm=document.getElementById('lmid');
lm.innerHTML=data+"</select>";
}
<%Conn.Close:Set Conn=Nothing%>
调用页面代码
复制代码 代码如下:
<%
Dim lm
lm=request("lm")
if lm=Empyt or Not Isnumeric(lm) then lm=0
%>
<html>
<script type="text/javascript" src="*.asp"></script>
<body onLoad="CheckLm(<%=lm%>)">
<div id="lmid"></div>
</body>
</html>
运行后结果