mySelect = new Array();
mySelect[0] = new Array("桂林街道","朝阳区","/shequ/selectServlet?key=桂林街道");
mySelect[1] = new Array("红旗街道","朝阳区","/shequ/selectServlet?key=红旗街道");
mySelect[2] = new Array("湖西街道","朝阳区","/shequ/selectServlet?key=湖西街道");
mySelect[3] = new Array("南湖街道","朝阳区","/shequ/selectServlet?key=南湖街道");
mySelect[4] = new Array("南站街道","朝阳区","/shequ/selectServlet?key=南站街道");
mySelect[5] = new Array("清和街道","朝阳区","/shequ/selectServlet?key=清和街道");
mySelect[6] = new Array("永昌街道","朝阳区","/shequ/selectServlet?key=永昌街道");
mySelect[41] = new Array("桃源街道","南关区","/shequ/selectServlet?key=桃源街道");
mySelect[42] = new Array("永吉街道","南关区","/shequ/selectServlet?key=永吉街道");
mySelect[43] = new Array("自强街道","南关区","/shequ/selectServlet?key=自强街道");count=43;function csChoose(locationid)
{
document.myform.csList2.length = 0; var locationid=locationid;
var i;
document.myform.csList2.options[0] = new Option('====请选择====','');
for (i=0;i < count; i++)
{
if (mySelect[i][1] == locationid)
{
document.myform.csList2.options[document.myform.csList2.length] = new Option(mySelect[i][0], mySelect[i][2]);
}
}
}
</script>
<select name="csList" onChange="csChoose(document.myform.csList.options[document.myform.csList.selectedIndex].value)">
<option value="">===请选择===</option>
<option value="朝阳区">朝阳区</option>
<option value="二道区">二道区</option>
<option value="高新区">高新区</option>
<option value="经济开发区">经济开发区</option>
<option value="宽城区">宽城区</option>
<option value="绿园区">绿园区</option>
</select>
<select name="csList2" onchange="window.location.href=this.options[this.selectedIndex].value">
<option selected value="">==请选择==</option>
</select>
<br>
<br>
</td></tr></table> 我做的二级联动菜单,现在想在二级下拉菜单改变的时候去调用js脚本中的startRequest()
但是这里onchange="window.location.href=this.options[this.selectedIndex].value" 需要获得
二级菜单的值,我不指导如何把这个参数给脚本传递过去请大家指教
mySelect[0] = new Array("桂林街道","朝阳区","/shequ/selectServlet?key=桂林街道");
mySelect[1] = new Array("红旗街道","朝阳区","/shequ/selectServlet?key=红旗街道");
mySelect[2] = new Array("湖西街道","朝阳区","/shequ/selectServlet?key=湖西街道");
mySelect[3] = new Array("南湖街道","朝阳区","/shequ/selectServlet?key=南湖街道");
mySelect[4] = new Array("南站街道","朝阳区","/shequ/selectServlet?key=南站街道");
mySelect[5] = new Array("清和街道","朝阳区","/shequ/selectServlet?key=清和街道");
mySelect[6] = new Array("永昌街道","朝阳区","/shequ/selectServlet?key=永昌街道");
mySelect[41] = new Array("桃源街道","南关区","/shequ/selectServlet?key=桃源街道");
mySelect[42] = new Array("永吉街道","南关区","/shequ/selectServlet?key=永吉街道");
mySelect[43] = new Array("自强街道","南关区","/shequ/selectServlet?key=自强街道");count=43;function csChoose(locationid)
{
document.myform.csList2.length = 0; var locationid=locationid;
var i;
document.myform.csList2.options[0] = new Option('====请选择====','');
for (i=0;i < count; i++)
{
if (mySelect[i][1] == locationid)
{
document.myform.csList2.options[document.myform.csList2.length] = new Option(mySelect[i][0], mySelect[i][2]);
}
}
}
</script>
<select name="csList" onChange="csChoose(document.myform.csList.options[document.myform.csList.selectedIndex].value)">
<option value="">===请选择===</option>
<option value="朝阳区">朝阳区</option>
<option value="二道区">二道区</option>
<option value="高新区">高新区</option>
<option value="经济开发区">经济开发区</option>
<option value="宽城区">宽城区</option>
<option value="绿园区">绿园区</option>
</select>
<select name="csList2" onchange="window.location.href=this.options[this.selectedIndex].value">
<option selected value="">==请选择==</option>
</select>
<br>
<br>
</td></tr></table> 我做的二级联动菜单,现在想在二级下拉菜单改变的时候去调用js脚本中的startRequest()
但是这里onchange="window.location.href=this.options[this.selectedIndex].value" 需要获得
二级菜单的值,我不指导如何把这个参数给脚本传递过去请大家指教
解决方案 »
- struts2<s:textfield>value默认值的问题
- java applet与javascript通信希望有详细点的例子
- 请教:如何如实的保留html select 各个选项中的空格??现在是所有空格都换成了一个。select的各个Option是通过jstl <c:out> 返回的字符
- 如何 在 JAVA中创建 sqlserver 数据库 或 执行sql脚本 来创建数据库~!在线等 ...
- 中文路径的问题
- 一个关于在页面上显示HTML的问题~~
- 一个Jsp的问题!
- 用dropdownlist从库中读取的数据显示时多了中括号[]怎么把它去掉?
- 求助:动态select下拉框.
- SOS:: help me !!!!一段连接数据库的程序,总是出错,请各位DX帮忙看看啊
- 向一张表中的字段插入大数据量的问题?
- List接口版本不兼容?
还有你这个 document.myform.csList2.length = 0; 这段是什么意思
我看你估计是头昏了
我猜你是想构造一个select 那你直接用js构造下整个select好了
一点要怎么想办法给select设置option干什么呢 (主要是我也不知道怎么搞)
你就在页面上搞个<div id="csList2"> </dive>
然后在js里搞个select的字符串给这个div就好了
{
var locationid=document.getElementsByName('csList')[0].value;
...................................................
}
alert(document.myform.csList2.value);
//window.location.href=....
}
这里我写了一个3级联动的。从数据库里取值。。
可以参考一下~!
顶楼上~