求三级省 市 区的级联菜单的源码,要求菜单内容数据库读取 高分有的请发[email protected]
包括,表结构,页面部分,等全部代码,谢谢啊,本人着急用
包括,表结构,页面部分,等全部代码,谢谢啊,本人着急用
解决方案 »
- SSH下checkbox批量保存的问题
- struts2页面显示的问题
- dom4j 怎么读取网络上的xml
- Ajax req.responseXML.documentElement 为何为null ?
- 两个TOMCAT的初级问题
- 什么HTML编辑器兼容性好,支持WORD好,而且免费。
- 请问用delete from db1 where id='1234'; 为什么删除不了数据?怎样删除?在servlet里
- 高手请进!!!(在线候)
- 新人,新手.请高手帮忙.JSP嵌套循环问.谢谢!!!
- 急用, 如何能編譯使用import javax.servlet.*; 的java文件
- jsp页面提交 提示 内存溢出 在线等
- 50分求救:怎样使Apache支持Servlet
所有数据从数据库中读取
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)">
id name parentid
有这三个最主要的字段就可以了,然后第一级的parentid为null,因为它没有父类,至于第二级,第三级的,都有父类,这样就可以控制住了
你可以参考以下的这篇文章:
http://dev2dev.bea.com.cn/bbs/thread.jspa?
forumID=121&threadID=37006&messageID=219585#219585
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)%>
</select>
<script language=javascript>
var bm= new Array();
<%if(depAll.length>0){
for(int i=0;i<depAll.length;i++){%>
bm[<%=i%>] = new Array("<%=depAll[i].getCom()%>","<%=depAll[i].getID()%>","<%=depAll[i].getName()%>");
<%}}%>
function setBm(){
document.form_com_dep.deptid.length = 0;
document.form_com_dep.deptid.options[document.form_com_dep.deptid.length] = new Option("所有部门","");
var comp = document.form_com_dep.compid.value ;
var i=0;
for (i=0;i < <%=depAll.length%> ; i++) {
if (bm[i][0] == comp ) {
document.form_com_dep.deptid.options[document.form_com_dep.deptid.length] = new Option(bm[i][2], bm[i][1]);
}
}
}
</script>