日期:2014-05-17  浏览次数:20953 次

asp联级菜单问题
我的目的是通过   下拉列表值的改变  
用java脚本   填充其联级下拉菜单的值

function       MulSelect(x)
{
SQL= "select   *   from   Stockpile   where   Productsecid= "&x
}

x   是js变量   客户端
asp   服务器端
我想无刷新得到变量值   不知道能不能实现
可能我的想法   有问题
希望高手指点


代码如下:

<select   name= "ProductType "   id= "PrductType "   onchange= "MulSelect   this.options[this.selectedIndex].value) ">
</select>

<script   language= "javascript ">      

    function       MulSelect(x)    
    {    
    var   i
    i=0
for   (var   m=document.form1.ProductName.options.length;m> 0;m--)  
document.form1.ProductName.options[m]=null
document.form1.ProductName.options[i]=new   Option( "请选择商品名称 ", " ")  
i=i+1;

<%
SQL= "select   *   from   Stockpile   where   Productsecid= "&x
set   rs=server.CreateObject( "ADODB.RecordSet ")
SET   rs=conn.EXECUTE(SQL)

while   not   rs.eof  
%>  
document.form1.ProductName.options[i]=new   Option( " <%=rs( "ProductName ")%> - <%=rs( "ProductProvide ")%> ", " <%=rs( "ID ")%> ")  
i=i+1;
<%  
rs.movenext  
wend
%>      
}

</script>

------解决方案--------------------
<script language= "JavaScript ">
<!--
<%
'二级数据保存到数组
Dim count1,smallRS,smallSQL
set smallRS=server.createobject( "adodb.recordset ")
smallSQL= "select * from smallClass "
smallRS.open smallSQL,conn,1,1
%>
var subval = new Array();
//数组结构:一级根值,二级根值,二级显示值
<%
count1 = 0
do while not smallRS.eof
%>
subval[ <%=count1%> ] = new Array( ' <%=smallRS( "bigClassID ")%> ', ' <%=smallRS( "id ")%> ', ' <%=smallRS( "className ")%> ')
<%
count1 = count1 + 1
smallRS.movenext
loop
smallRS.close
%>
function changeselect(locationid)
{
document.form1.smallClass.length = 0;
document.form1.smallClass.options[0] = new Option( '=请选择子栏目= ', ' ');
for (i=0; i <subval.length; i++)
{
if (subval[i][0] == locationid)
{document.form1.smallClass.options[document.form1.smallClass.length] = new Option(subval[i][2],subval[i][1]);}
}
}
//-->
</script>
<%
dim bigRS,bigSQL
set bigRS = server.CreateObject( "adodb.recordset ")
bigSQL = "select * from bigClass where channelID= "&channelID& " order by id desc "
bigRS.open bigSQL,conn,1,1
%>
<select name= "bigClass " class= "buttonmain " id= "bigClass " onChange= "changeselect(this.value) ">
<option value= " "> =请选择栏目= </option>
<%
count1 = 0
do while not bigRS.eof
%>
<option value= " <%=bigRS( "ID ")%> "> <%=bigRS( &quo