请求大家帮我解决一个动态级联菜单的问题吧,小弟快风了
代码如下:
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
int count = 0;
for(int i=0;i<cartype1.size();i++)
{
CarType ct1 = (CarType)cartype1.get(i);
String cartypename2 = ct1.getCartypename();
String carnameid2 = ct1.getCarnameid();
String cartypeid2 = ct1.getCartypeid();
%>
<%count = count + 1;%>
subcat[<%=count%>] = new Array("<%=cartypename2%>","<%=carnameid2%>","<%=cartypeid2%>");
<%}%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.form.smalllocation.length = 0;
var locationid=locationid;
var i;
document.form.smalllocation.options[0] = new Option('====所有地区====','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.form.smalllocation.options[document.form.smalllocation.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<select name="biglocation" onChange="changelocation(document.form.biglocation.options[document.form.biglocation.selectedIndex].value)">
<option value="" selected>选择车名</option>
<%
for(int i=0;i<carname.size();i++)
{
CarName cn = (CarName)carname.get(i);
String carnameid1 = cn.getCarnameid();
String carname1 = cn.getCarname();
%>
<option value="<%=carnameid1%>"><%=carname1%></option>
<%
}
%>
</select>
<select name="smalllocation">
<option value="" selected>选择车型</option>
</select>
<script LANGUAGE="javascript">
changelocation(document.form.biglocation.options[document.form.biglocation.selectedIndex].value);
</script>
运行后第2个下拉菜单没有内容,第1个可以正常显示,什么错误也不报,我都快风了 弄了好几个小时了都弄不好,请高手帮帮忙啊!
万分感谢了
------解决方案--------------------级联菜单网上有现成的可以用,比你自己写来得好
------解决方案--------------------csdn上就有,你自己搜搜看
------解决方案--------------------两方数据都不固定ajax
一方数据固定
http://blog.csdn.net/sunyujia/archive/2008/01/13/2040748.aspx