我写的 http://www.prctj.com/shop/tzsc/
我有两个表,一个大类表BType,一个子类表SubType
<select name="TypeID" id="TypeID" onChange="JavaScript:ShowSubType(this.options[this.selectedIndex].tag)">
<option value="">选择大类</option>
<%
Dim RecordCount,BTypeArr
Rs.Open "Select TypeName,TypeID from BType",Conn,1,1
RecordCount=Rs.RecordCount
If RecordCount>0 Then
Redim BTypeArr(RecordCount-1)
For i=0 To RecordCount-1
SqlStr="Select SubTypeID,SubTypeName From SubType Where TypeID=" & Rs("TypeID")
Rs1.Open SqlStr,Conn
'BTypeArr(i)="<option value=''>选择小类</option>"
While Not Rs1.Eof
BTypeArr(i)=BTypeArr(i) & "<option value='" & Rs1("SubTypeID") & "'>" & Rs1("SubTypeName") & "</option>"
Rs1.MoveNext
Wend
Rs1.Close
%>
<option value="<%=Rs("TypeID")%>" tag=<%=i%>><%=Rs("TypeName")%></option>
<%
Rs.MoveNext
Next
End If
Rs.Close
%>
</select>
<select name="SubTypeID">
<option value="">选择小类</option>
</select>
<%If RecordCount>0 Then%>
<script language="JavaScript">
var BTypeArr=new Array();
<%
For i=0 To RecordCount-1
%>
BTypeArr[<%=i%>]="<%=BTypeArr(i)%>";
<%
Next
%>
function ShowSubType(Index)
{
document.frmSearch.SubTypeID.outerHTML="<select name='SubTypeID'><option value=''>选择小类</option>" + BTypeArr[Index] + "</select>";
}
</script>
<%End If%>
[此贴子已经被作者于2004-07-12 22:31:28编辑过]