请参考如下代码:(已运行成功)
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
</head>
<%
String TProduct_ID="10000000,10000001,10000002,10001000";//你可改成从数据库中取出数据,并进行累加成字符串
String TCategory_ID="1000,1001,1002,1000";";//你可改成从数据库中取出数据,并进行累加成字符串,同时将各个数据放入数组ACategory_ID
String[] ACategory_ID={"1000","1001","1002","1000"};//意义:即为各产品ID对应的分类ID,与TProduct_ID一一对应
int Counter=Acategory_ID.length;
%>
<body bgcolor="#FFFFFF" text="#000000">
<table width="778" border="0" cellspacing="0" cellpadding="0" height="100">
<FORM action="/OrderOnnet/AddOrderForm2.asp" method=POST id=FormAddTempInfo name=FormAddTempInfo LANGUAGE=javascript onsubmit="return FormAddTempInfo_onsubmit()">
<tr bgcolor="#FFFFFF">
<td><SELECT id=Category_ID name=Category_ID LANGUAGE=javascript onchange="return Category_ID_onchange()">
<OPTION value="0" selected>请选择产品分类</OPTION>
<%
for(int i=0;i<ACategory_ID.length;i++){
%>
<OPTION value="<%=ACategory_ID%>"><%=ACategory_ID%></OPTION>
<%
}
%>
</SELECT></td>
<td colspan=2><div id="Product_Display"><SELECT id=Product_ID name=Product_ID>
<OPTION value="0" selected>请选择详细产品</OPTION>
</SELECT></div></td>
<td align="center">
<input type="text" name="Order_Number" id="Order_Number" class="formcss" size="6" value="1">
</td>
</tr>
</FORM>
</table>
<SCRIPT LANGUAGE=javascript>
<!--
var Ary_Product_ID=FormAddTempInfo.Ary_Product_ID.value.split(',');
var Ary_Category_ID=FormAddTempInfo.Ary_Category_ID.value.split(',');
var Counter;
Counter=<%=Counter%>;
function Category_ID_onchange()
{
var Category_ID;
Category_ID =do
cument.FormAddTempInfo.Category_ID.value;
var OutPutText;
OutPutText="";
if (Category_ID==0)
{
OutPutText = '<SELECT id=Product_ID name=Product_ID><OPTION value="0" selected>请选择详细产品</OPTION></SELECT>';
Product_Display.innerHTML = OutPutText;
}
else
{
OutPutText = '<SELECT id=Product_ID name=Product_ID><OPTION value="0" selected>请选择详细产品</OPTION>';
for (var Counter1=0;Counter1<Counter;Counter1++)
{
if (Ary_Category_ID[Counter1]==Category_ID)
{
OutPutText = OutPutText + '<Option Value="' + Ary_Product_ID[Counter1] + '">' + Ary_Product_ID[Counter1] + '</Option>';
}
}
OutPutText = OutPutText + '</SELECT>';
Product_Display.innerHTML = OutPutText;
}
}
//-->
</SCRIPT>
</body>
</html>
你可参考http://www.csdn.net/Subject/237/index.shtm