`

jsp Select 级联

阅读更多
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html; charset=GBK"%>
<%@taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@taglib uri="/WEB-INF/struts-nested.tld" prefix="nested"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@page import="com.ist.util.db.Result"%>

<%
String deptcode = (String) request.getSession().getAttribute(
"deptcode");
int depttype = Integer.parseInt((String) request.getSession()
.getAttribute("depttype"));  //一级部门
String reportid = request.getParameter("reportid");
String[] deptTitle = new String[] { "省", "市", "县/区", "支" };
String title0 = "";
String title1 = null;
String title2 = null;
String title3 = null;
if (1 == depttype) {    //一级部门
title0 = "全省";
title1 = "市";
title2 = "县";
title3 = "支";
} else {                   //不是省级部门
if (depttype < deptTitle.length)  
title1 = deptTitle[depttype];
if (depttype < deptTitle.length - 1)
title2 = deptTitle[depttype + 1];

if (depttype < deptTitle.length - 2)
title3 = deptTitle[depttype + 2];

if (title1 != null)
title0 = "全" + deptTitle[depttype - 1];
}
%>
<html>
<title>营业环节结算支出表</title>
<script src="/js/cssjs.js" type="text/javascript"></script>
<script src="/js/zfwl.js" type="text/javascript"></script>
<script src="/js/jquery-1.4.2.min.js" type="text/javascript"></script>

<script type="text/javascript">
  

function  lstLowLowerDept(lowerDeptObj,lowerLowDeptObj){
lowerLowDeptObj.options.length = 0;
var o = lowerDeptObj.options;   //上级机构长度
for(var i=0; i<o.length; i++) {
if(o[i].selected) {  //选中第几行
var deptCode=o[i].value;
var strUrl = "/report.do?command=QueryInfo&deptCode="+deptCode+"&reportid=<%=reportid%>" ;
jQuery.ajax({
type : "POST",
async: false,
url :strUrl,
data : "",
success : function callback(data) {  
var optionValue=  eval("("+data+")");
    for(var i=0;i<optionValue.length;i++){
   lowerLowDeptObj.options.add(new Option(optionValue[i].deptName,optionValue[i].deptCode));  //添加新的option
    } 
}
}); 
   }

}
  
//js数组 三个标题
var deptTitle = new Array("<%=title1%>","<%=title2%>","<%=title3%>");
function getForm() {
return reportForm;
}
function doSubmit(no) {
var theForm = getForm();
var html = "";
if(no != 0) {  //不是查询qua'she
// var deptObj = no==1? theForm.dept1:theForm.dept2; 
var deptObj=null;
if(no==1){
deptObj= theForm.dept1;
}else if(no==2){
deptObj= theForm.dept2;
}else{
deptObj= theForm.dept3;
}
for(var i=0; i<deptObj.options.length; i++) {
  if(deptObj.options[i].selected) {
    html += "<input type='hidden' name='dept' value='"+deptObj.options[i].value.substring(deptObj.options[i].value.indexOf("|")+1)+"'>";    
  }
  }

  if(html=="") {
  alert("请选择" + deptTitle[no-1] + "机构!");
  return;
  }
 
//查询第一个机构列表,且第二个机构列表存在
//则进入报表页面后还可继续往下查
if(no==1 && deptTitle[1]!="null") theForm.hasLower.value = "1";
else theForm.hasLower.value = "0";
}
else {  //查询全省
html = "<input type='hidden' name='dept' value='<%=deptcode%>'>";
if(deptTitle[0]=="null" && deptTitle[1]=="null") theForm.hasLower.value = "0";
else {
if(deptTitle[0]!="null") theForm.hasLower.value = "1";
if(deptTitle[1]!="null") theForm.hasLower.value = "2";
}
}
document.all["deptDiv"].innerHTML = html;
openProcessBar();
theForm.submit();
}


function clearLowerLowdept(lowLowerDept){
  lowLowerDept.options.length=0;
}

</script>
<link href="/css/themes/spread.css" rel="stylesheet" type="text/css"></link>
<link href="/css/themes/default.css" rel="stylesheet" type="text/css"></link>
<link href="/css/themes/alphacube.css" rel="stylesheet" type="text/css"></link>
<link href="/css/themes/alert.css" rel="stylesheet" type="text/css">
</link>
<link href="/css/themes/alert_lite.css" rel="stylesheet"
type="text/css">
</link>
<script type="text/javascript" src="/js/prototype/prototype.js"> </script>
<script type="text/javascript" src="/js/prototype/window.js"> </script>
<link href="/css/zfwl.css" type=text/css rel=STYLESHEET>
</HEAD>
<body vlink=#000000 alink=#000000 link=#000000 bgColor=#ffffff>
<html:form action="/report.do" method="post">
<input type="hidden" name="command" value="Query">
<input type="hidden" name="hasLower" value="0">
<input type="hidden" id="reportid" name="reportid" value="<%=reportid%>">
<div id="deptDiv"></div>
<!-- 标题栏 -->
<div class=SectionTabTopBorder style="DISPLAY: block">
</div>
<div class=SectionTabBackground id=idSectionTabBackground 
style="DISPLAY: block">
<table style="HEIGHT: 2em" border=0>
<tr>
<td class=TabCell>
<font class="beta" size="2"> &nbsp; <b>营业环节结算</b>
&nbsp;&nbsp; <span class="bg-neg-alert">&raquo;</span>
&nbsp;&nbsp; <b>营业环节结算支出表</b> &nbsp; </font>
</td>
</tr>
</table>
</div>
<!-- 查询栏 -->
<table cellspacing=0 bordercolordark=#ffffff cellpadding=3
width="100%" align=center bordercolorlight=#000000 border=1>

  <!-- 第一行 -->
<tr>
<td class="beta" style="font-weight:bold" width="60px">
结算周期:
</td>
<td colspan=10>
<logic:present name="lstSettlePeriod">
<html:select property="settlePeriod" style="width:130px">
<html:options collection="lstSettlePeriod" property="value"
name="LabelValueBean" labelProperty="label" />
</html:select>
</logic:present>
</td>
</tr>
<%
if (title1 != null || title2 != null|| title3 != null) {
%>

<!--tr2-->
<tr>
<!--左边机构栏-->

<!--td1-->
<td class="beta" style="font-weight:bold" width="80px">
<%=title1%>
局:
</td>

<!--td2-->
<td>
<select name="dept1" style="width:180px;height:200px"
multiple="true"
onchange="lstLowerDept(getForm().dept1,getForm().dept2,lowerDeptArray),clearLowerLowdept(getForm().dept3)">
<%
Result cityDept = (Result) request.getAttribute("lstLowerDept");

if (cityDept != null) {
for (int i = 0; i < cityDept.size(); i++) {
%>
<option
value="<%=cityDept.getValue(i, "dept_id") + "|"
+ cityDept.getValue(i, "dept_code")%>">
<%=cityDept.getValue(i, "dept_name")%>
</option>
<%

}
%>
</select>
<br>
全选
<input type="checkbox"
onclick="selectAll(getForm().dept1);lstLowerDept(getForm().dept1,getForm().dept2,lowerDeptArray)" />
<input type="button" value=" 查 询 " onclick="doSubmit(1)">
</td>




<!--右边机构栏-->
<%
if (title2 != null) {
%>
<td class="beta" style="font-weight:bold" width="80px">
<%=title2%>
局:
</td>
<td>
<select name="dept2" style="width:180px;height:200px"
multiple="true"
onchange="lstLowLowerDept(getForm().dept2,getForm().dept3)">
</select>
<br>
全选
<input type="checkbox" onclick="selectAll(getForm().dept2);" />
<input type="button" value=" 查 询 " onclick="doSubmit(2)">
</td>
<%
}
%>

<%
if (title3!= null) {
%>

<td class="beta" style="font-weight:bold" width="80px">
    
<%=title3 %>
局:
</td>
<td>
<select name="dept3" style="width:180px;height:200px"
multiple="true">
</select>
<br>
全选
<input type="checkbox" onclick="selectAll(getForm().dept3);" />
<input type="button" value=" 查 询 " onclick="doSubmit(3)">
</td>
<%
    }
%>
</tr>
<%
}
%>
</table>
<input type="button" value=" 查询<%=title0%> " onclick="doSubmit(0)">
</html:form>
</body>
</html>
<script>
var lowerDeptArray = new Array();
<%
Result cityDept = (Result)request.getAttribute("lstLowlowerDept");
if(cityDept !=null) {
  for(int i=0; i<cityDept.size(); i++) {
%>
lowerDeptArray.push(new Dept("<%=cityDept.getValue(i, "upper_dept_id")%>","<%=cityDept.getValue(i, "dept_id") + "|"
+ cityDept.getValue(i, "dept_code")%>","<%=cityDept.getValue(i, "dept_name")%>"));
<%
}
}
%>
  //放第二个菜单的内容

</script>






分享到:
评论

相关推荐

    struts实现select级联

    struts实现select级联,没有连接数据库

    JSP Ajax省市县Select级联菜单.rar

    JSP Ajax省市县Select级联菜单,无刷新调用城市数据并显示。

    JSP页面中如何用select标签实现级联

    在JSP页面中如何用select标签实现级联呢?以下小编就为大家介绍实现方法,需要的朋友可以参考下

    省市县三级级联select

    里面有三个文件,jq和html放一起,pro省市县文件最好和你的jsp界面在同一目录下

    AJAX_Servlet级联下拉列表

    AJAX_Servlet级联下拉列表 product.jsp UserServlet.java

    下拉菜单的级联操作(ajax)

    ①使用js来实现,把页面所用到的级联数据放到js内,当页面加载完成后,通过js显示到对应的select内,这种方法的解决办法有很多种,最为直观的一种是放到多维数组中,每个人的思维不一样,这里就不详细解说。...

    jsp从数据库获取数据填充下拉框实现二级联动菜单的方法

    本文实例讲述了jsp从数据库获取数据填充下拉框实现二级联动菜单的方法。分享给大家供大家参考,具体如下: 项目告一段落,现在将遇到的比较实用的东西记录下来,写了多遍了,谨记于此,以备查看! 1、首先在数据库中...

    dwr验证框架多级联下拉菜单

    index.jsp(级联的重点) ; charset=gb2312" language="java" import="java.sql.*" errorPage=""%&gt; &lt;jsp:useBean id="connDB" class="com.core.ConnDB" scope="page"/&gt; ResultSet rs_city = null; ResultSet rs_...

    Ajax实现二级联动菜单

    index.jsp &lt;&#37;@ page language=java pageEncoding=UTF-8%&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;二级菜单联动演示&lt;/title&gt; [removed] var req; window.οnlοad=function() {//页面加载时的...

    低清版 大型门户网站是这样炼成的.pdf

    5.1.11 持久化对象间的级联操作 277 5.2 hibernate的检索策略 291 5.2.1 立即检索 291 5.2.2 延迟检索 296 5.2.3 迫切左外连接检索 300 5.3 hql查询方式 303 5.3.1 基本查询 303 5.3.2 条件查询 305 5.3.3 ...

    Ajax二级联动菜单实现原理及代码

    index.jsp: 代码如下: &lt;&#37;@ page language=”java” pageEncoding=”UTF-8″%&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;二级菜单联动演示&lt;/title&gt; [removed] var req; [removed]=function() {//页面...

    EXT教程EXT用大量的实例演示Ext实例

    4.4.7. 露一小手,组合上面所知,省市县三级级联。哈哈~ 4.4.7.1. 先做一个模拟的,所有数据都在本地 4.4.7.2. 再做一个有后台的,需要放在服务器上咯 4.5. 把form里的那些控件全部拿出来看看 4.6. form提交数据...

    Java学习笔记-个人整理的

    \contentsline {chapter}{Contents}{2}{section*.1} {1}Java基础}{17}{chapter.1} {1.1}基本语法}{17}{section.1.1} {1.2}数字表达方式}{17}{section.1.2} {1.3}补码}{19}{section.1.3} {1.3.1}总结}{23}{...

    EXT2.0中文教程

    4.4.7. 露一小手,组合上面所知,省市县三级级联。哈哈~ 4.4.7.1. 先做一个模拟的,所有数据都在本地 4.4.7.2. 再做一个有后台的,需要放在服务器上咯 4.5. 把form里的那些控件全部拿出来看看 4.6. form提交数据的...

    Ext 开发指南 学习资料

    4.4.7. 露一小手,组合上面所知,省市县三级级联。哈哈~ 4.4.7.1. 先做一个模拟的,所有数据都在本地 4.4.7.2. 再做一个有后台的,需要放在服务器上咯 4.5. 把form里的那些控件全部拿出来看看 4.6. form提交数据的...

Global site tag (gtag.js) - Google Analytics