当前位置: 代码迷 >> Java Web开发 >> 求三级省份 市 区的级联菜单的源码,要求菜单内容数据库读取 高分
  详细解决方案

求三级省份 市 区的级联菜单的源码,要求菜单内容数据库读取 高分

热度:591   发布时间:2016-04-17 15:03:45.0
求三级省 市 区的级联菜单的源码,要求菜单内容数据库读取 高分
求三级省   市   区的级联菜单的源码,要求菜单内容数据库读取   高分

有的请发sunsja@126.com
包括,表结构,页面部分,等全部代码,谢谢啊,本人着急用

------解决方案--------------------
页面 jsp
所有数据从数据库中读取
------解决方案--------------------
你可以参考我的实现方法:
1.JavaScript方法:
//当局下拉列表的值确定的时候,那么处下拉列表的值也随之变化
function juChange(parentId){
//当局下拉列表的值变化的时候,将处下拉列表的值进行清空,避免出现处和下拉列表的值重复的情况
document.formAct.chu.length=0;
//得到处记录集的所有个数,并将其赋给js变量count
var count = <%=chuList.size()%> ;
//定义一个js数组,将所有处站点的数据集逐一赋给js数组
var selChu = new Array();
<%
for(int i=0;i <chuList.size();i++){
int id = (((Dept)chuList.get(i)).getId()).intValue();
String name = ((Dept)chuList.get(i)).getName();
Integer pid = ((Dept)chuList.get(i)).getParentid();
System.out.println( "id= "+id+ " name= "+name+ " pid= "+pid);
%>
selChu[ <%=i+1%> ]=new Array( " <%=id%> ", " <%=name%> ", " <%=pid%> ");
<%
}
%>
selChu[0]=new Array( " ", " ",parentId);
for(var i=0;i <count+1;i++){
if(selChu[i][2]==parentId){
document.formAct.chu.options[document.formAct.chu.length] =
new Option(selChu[i][1],selChu[i][0]);
}
}
}
2:在下拉列表中添加如下方法:
<select name= "ju " style= "width:220 "
onchange= "juChange(document.formAct.ju.options[document.formAct.ju.selectedIndex].value) ">
------解决方案--------------------
只要一张表就ok了,

就是一个树嘛,省是市的根,市是县的根,搜搜很多的
------解决方案--------------------
关注.
------解决方案--------------------
//=================公司类方法===================//
public String getDrop(String compid,String dataid) throws Exception{
if(str.IsEmpty(dataid) )
dataid= "AAA ";
Compid com[]=this.readAll(compid,dataid);
StringBuffer bf = new StringBuffer();
if(com.length > 0){
for(int i=0;i <com.length ;i++){
if(dataid.equals(com[i].getBh()) )
bf.append( " <option value= " + com[i].getID() + " selected > " + com[i].getName() + " </option> ") ;
else
bf.append( " <option value= " + com[i].getID() + "> " + com[i].getName() + " </option> ") ;
}
}
return bf.toString();
}
//=================部门类方法同上===================//

//====================页面调用=====================//

Compid com = new Compid();
Deptid dep = new Deptid();
Deptid [] depAll=bm.readAll( " ", " ");

<select name= "deptid " style= "width:120px ">
<option value= " "> 所有公司
<%=com.getDrop(compid,deptid)%>
</select>

<select name= "deptid " style= "width:120px ">
<option value= " "> 所有部门
<%=dep.getDrop(compid,deptid)%>
  相关解决方案