- 浏览: 52144 次
文章分类
- 全部博客 (87)
- 模糊查询 (1)
- 树查询 (1)
- 汉字文件编码 (1)
- 图片文件写入网页 (1)
- 网络爬虫 (1)
- 正则表达式实现IP排序 (1)
- javax读取xml (1)
- javax增删改查xml (1)
- java反射 (1)
- dom4j操作XML文件 (1)
- descode函数 (1)
- 用户在线管理 (1)
- oracle统计函数统计各个年份入职的人数 (1)
- js解绑时间和自定义时间 (1)
- extjs 树控件开发 (1)
- java导出excel (1)
- java导入excel... (1)
- 行转列 (1)
- 连接池 (1)
- oracle plsql (0)
- oracle (1)
- oracle存储过程 (5)
- plsql编程 (5)
- oracle触发器 (2)
- oracle知识 (1)
- web技术 (22)
- servle+jspt文件下载 (0)
- wen技术 (0)
- java连接池 (1)
- java基础 (10)
- weblogic (3)
- jstl标签库的使用 实例 (1)
- css技术 (1)
- 存储过程 (1)
- sql统计 (1)
- webservice技术 (5)
- spring框架总结 (1)
- mongoDB (1)
- 64位oracle安装plsql (1)
- mongoDB分组统计 (1)
- ssh 无密码登录 (0)
- mysql (1)
- hadoop (0)
- lucene (1)
最新评论
jsp Select 级联
- 博客分类:
- web技术
<%@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"> <b>营业环节结算</b>
<span class="bg-neg-alert">»</span>
<b>营业环节结算支出表</b> </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>
<%@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"> <b>营业环节结算</b>
<span class="bg-neg-alert">»</span>
<b>营业环节结算支出表</b> </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>
发表评论
-
excel 导出及单元格合并
2014-08-13 16:00 517合并单元格类 public ActionForward do ... -
jsp动态生成table并且进行表头表列合并
2014-07-31 08:54 1426<%@page import="java.ut ... -
jsquery解析XMl文件二级联动实现
2014-07-26 21:14 551xml文件 <?xml version="1. ... -
json使用
2014-07-20 12:46 331后台 String json="[{'key' ... -
通过中文转码使用包装类
2014-07-13 22:48 522jsp <%@ page language=" ... -
struts1标签循环里面的判断
2014-07-07 10:21 508<%@ page language="java ... -
自定义标签库循环数组 list map输出
2014-07-07 08:24 902jsp <%@ page language=" ... -
自定义标签库读取list输出
2014-07-06 14:59 352jsp <%@ page language=" ... -
jsp标签循环数字到jsp页面
2014-07-06 13:53 514jsp <%@ page language=" ... -
自定义标签库读取文件
2014-07-06 11:38 376jsp <%@ page language=" ... -
jsp自动标签实现字母转换
2014-07-06 11:35 323jsp <%@ page language=" ... -
jsp自定义标签实现比较两个数值的大小
2014-07-06 11:33 799jsp <%@ page language=" ... -
jstl自定义标签库入门
2014-07-05 10:39 4081.先写java代码 package com.cgm.tldt ... -
jsp调用普通java类实例
2014-07-05 10:10 4161.jsp页面 <%@ page language= ... -
jstl c标签库的使用
2014-07-05 09:27 377<%@ page language="java ... -
文件多线程下载
2014-07-04 08:27 581//线程下载类 package com.c ... -
HttpURLConnection实现断点下载
2014-07-02 23:35 2096package cn.demo; import java.i ... -
java不依赖浏览器的(HttpUrlConnection)单线程不间断下载
2014-07-02 23:01 533package cn.demo; import java.io ... -
HttpUrlConnection模拟浏览器发送请求
2014-07-02 22:32 512servlet...code package cn.itc ... -
servle+jspt文件下载
2014-07-02 22:22 487jsp code <%@ page language=& ...
相关推荐
struts实现select级联,没有连接数据库
JSP Ajax省市县Select级联菜单,无刷新调用城市数据并显示。
在JSP页面中如何用select标签实现级联呢?以下小编就为大家介绍实现方法,需要的朋友可以参考下
里面有三个文件,jq和html放一起,pro省市县文件最好和你的jsp界面在同一目录下
AJAX_Servlet级联下拉列表 product.jsp UserServlet.java
①使用js来实现,把页面所用到的级联数据放到js内,当页面加载完成后,通过js显示到对应的select内,这种方法的解决办法有很多种,最为直观的一种是放到多维数组中,每个人的思维不一样,这里就不详细解说。...
本文实例讲述了jsp从数据库获取数据填充下拉框实现二级联动菜单的方法。分享给大家供大家参考,具体如下: 项目告一段落,现在将遇到的比较实用的东西记录下来,写了多遍了,谨记于此,以备查看! 1、首先在数据库中...
index.jsp(级联的重点) ; charset=gb2312" language="java" import="java.sql.*" errorPage=""%> <jsp:useBean id="connDB" class="com.core.ConnDB" scope="page"/> ResultSet rs_city = null; ResultSet rs_...
index.jsp <%@ page language=java pageEncoding=UTF-8%> <html> <head> <title>二级菜单联动演示</title> [removed] var req; window.οnlοad=function() {//页面加载时的...
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 ...
index.jsp: 代码如下: <%@ page language=”java” pageEncoding=”UTF-8″%> <html> <head> <title>二级菜单联动演示</title> [removed] var req; [removed]=function() {//页面...
4.4.7. 露一小手,组合上面所知,省市县三级级联。哈哈~ 4.4.7.1. 先做一个模拟的,所有数据都在本地 4.4.7.2. 再做一个有后台的,需要放在服务器上咯 4.5. 把form里的那些控件全部拿出来看看 4.6. form提交数据...
\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}{...
4.4.7. 露一小手,组合上面所知,省市县三级级联。哈哈~ 4.4.7.1. 先做一个模拟的,所有数据都在本地 4.4.7.2. 再做一个有后台的,需要放在服务器上咯 4.5. 把form里的那些控件全部拿出来看看 4.6. form提交数据的...
4.4.7. 露一小手,组合上面所知,省市县三级级联。哈哈~ 4.4.7.1. 先做一个模拟的,所有数据都在本地 4.4.7.2. 再做一个有后台的,需要放在服务器上咯 4.5. 把form里的那些控件全部拿出来看看 4.6. form提交数据的...