The code can be optimized, please optimize according to your needs
illustrate:
So first store all classification readings in JS array (it may be a bit troublesome if the data volume is large)
When selecting, return the parent classification ID and find the corresponding classification from the array, and then display it to the user
Database design (you can add fields according to your own needs, what category does this category belong to, etc.)
Field type description
id automatic number record number
Cotename Text Classification Name
byid number parent classification ID (that is, for this table ID, the value of the root contact is 0)
Part of JS code (named *.asp)
The code copy is as follows:
<%Dimconn
Setconn=Server.CreateObject("ADODB.Connection")
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;"&_
"DataSource="&Server.MapPath("Cote.mdb")
conn.Open
%>
functionCheckLm(thevalue){
varbyid=newArray();
varcotename=newArray();
variable=newArray();
vari;
variable_s;
varbyid_s;
varcotename_s;
varthevalue_r;
vardata='<selectname="lm"onchange="CheckLm(this.value)">'
id_s="|";
cotename_s='-select-|';
<%setrs=server.CreateObject("adodb.recordset")
sql="select*from[DB_Cote]Orderbybyid,id"
rs.opensql,conn,1,1
i=0
ifnotrs.eofthen
dowhilenotrs.eof
response.Write("id["&i&"]="&rs("id")&";"&chr(10))
response.Write("byid["&i&"]="&rs("byid")&";"&chr(10))
response.Write("cotename["&i&"]='"&rs("cotename")&"';"&chr(10))
rs.movenext
i=i+1
loop
else
response.Write("id[0]=0;byid[0]=0;cotename[0]='No classification';")
endif
rs.close
setrs=nothing%>
if(thevalue==null||thevalue==undefined||thevalue==''){thevalue=0;}
//if(lmvalue==null||lmvalue==undefined||lmvalue==''){lmvalue=0;}
for(k=0;k<id.length;k++){