参考:http://dropdown-check-list.googlecode.com/svn/trunk/src/demo.html
一个jquery ui,实现html的多选下拉框,在下拉里面加checkbox,不改变页面的提交特性,只是动态的改变select选中的多选数据。
jsp页面例子:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*,java.text.*"%>
<%@ taglib prefix="c" uri="/jstl/c"%>
<%@ taglib prefix="fn" uri="/jstl/fn"%>
<%@ taglib prefix="fmt" uri="/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>纳税用户核定</title>
<link href="<%=path%>/css/css.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="<%=path%>/js/date/calendar.js"></script>
<script language="javascript" src="<%=path%>/js/date/date.js"></script>
<link rel="stylesheet" type="text/css"
href="<%=path%>/js/dropdownchecklist/ui.dropdownchecklist.css" />
<script type="text/javascript"
src="<%=path%>/js/dropdownchecklist/jquery.js"></script>
<script type="text/javascript"
src="<%=path%>/js/dropdownchecklist/ui.core.js"></script>
<script type="text/javascript"
src="<%=path%>/js/dropdownchecklist/ui.dropdownchecklist.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#POSITION").dropdownchecklist({firstItemChecksAll: true, maxDropHeight: 100});
});
</script>
</head>
<body οnlοad="qry()">
<form action="<%=path%>/xxhdAction.do?action=nshhdQuery"
id="formConditon" name="formCondition" method="post"
target="listFrame">
<table width="100%" height="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="60">
<table width="100%" border="0" height="60" cellpadding="0"
cellspacing="0">
<tr>
<td
background="<%=path%>/templates/images/inner/center_bg01.jpg">
<table width="100%" border="0" height="60" cellpadding="0"
cellspacing="0">
<tr>
<td width="8">
</td>
<td width="8">
</td>
<td width="40%" align="left" class="blue">
</td>
<td align="right" class="blue">
</td>
<td width="20" class="blue">
</td>
</tr>
<tr>
<td width="8">
</td>
<td width="8">
</td>
<td width="40%" align="left" class="blue">
<img src="<%=path%>/templates/images/inner/icon01.jpg" />
纳税用户核定
</td>
<td align="right" class="blue">
</td>
<td width="20" class="blue">
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table width="100%" align="center" border="0" cellpadding="0"
cellspacing="0" background="<%=path%>/templates/img/query_01.gif">
<tr>
<td height="10"></td>
</tr>
<tr>
<td>
<table width="98%" align="center" border="0"
class="blue-border" bordercolor="#CCCCCC">
<tr>
<td>
计算机代码:
</td>
<td>
<input type="text" name="JSJDM" value="${JSJDM}">
</td>
<td>
纳税人名称:
</td>
<td>
<input type="text" name="NSRMC" value="${NSRMC}">
</td>
<td>
纳税人状态:
</td>
<td>
<select name="NSRZT">
<option value="">
</option>
<c:forEach items="${nsrztInfoList}" var="info">
<c:if test="${info.NSRZTDM==NSRZT}">
<option value="${info.NSRZTDM}" selected="selected">
${info.NSRZTMC}
</option>
</c:if>
<c:if test="${info.NSRZTDM!=NSRZT}">
<option value="${info.NSRZTDM}">
${info.NSRZTMC}
</option>
</c:if>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td>
查询核定类型:
</td>
<td>
<!--<select name="POSITION">
<c:choose>
<c:when test="${POSITION==null||POSITION==''}">
<option value="" selected="selected">
</option>
</c:when>
<c:otherwise>
<option value="">
</option>
</c:otherwise>
</c:choose>
<c:forEach items="${hdlxInfoList}" var="info">
<c:if test="${info.POSITION==POSITION}">
<option value="${info.POSITION}" selected="selected">
${info.XLMC}
</option>
</c:if>
<c:if test="${info.POSITION!=POSITION}">
<option value="${info.POSITION}">
${info.XLMC}
</option>
</c:if>
</c:forEach>
<input type="text" name="POSITION" listItem="${hdlxInfoList}">
</select>-->
<select id="POSITION" name="POSITION" multiple="multiple" width="100">
<option value="">
全选择
</option>
<c:forEach items="${dlInfoList}" var="dlInfo">
<optgroup label="${dlInfo.DLMC}">
<c:forEach items="${hdlxInfoList}" var="info">
<c:if test="${info.DLBM==dlInfo.DLBM}">
<option value="${info.POSITION}">
${info.XLMC}
</option>
</c:if>
</c:forEach>
</optgroup>
</c:forEach>
</select>
</td>
<td>
是否核定:
</td>
<td>
<select name="ISCHECK">
<option value=""></option>
<option value="1">
是
</option>
<option value="0">
否
</option>
</select>
</td>
<td>
税务机关:
</td>
<td>
<select name="SWJGZZJGDM">
<c:choose>
<c:when test="${SWJGZZJGDM==null||SWJGZZJGDM==''}">
<option value="" selected="selected">
</option>
</c:when>
<c:otherwise>
<option value="">
</option>
</c:otherwise>
</c:choose>
<c:forEach items="${swjgInfoList}" var="info">
<c:if test="${info.SWJGZZJGDM==SWJGZZJGDM}">
<option value="${info.SWJGZZJGDM}" selected="selected">
${info.JC}
</option>
</c:if>
<c:if test="${info.SWJGZZJGDM!=SWJGZZJGDM}">
<option value="${info.SWJGZZJGDM}">
${info.JC}
</option>
</c:if>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td>
登记注册类型:
</td>
<td>
<select name="DJZCLXDM">
<c:choose>
<c:when test="${DJZCLXDM==null||DJZCLXDM==''}">
<option value="" selected="selected">
</option>
</c:when>
<c:otherwise>
<option value="">
</option>
</c:otherwise>
</c:choose>
<c:forEach items="${djzclxInfoList}" var="info">
<c:if test="${info.DJZCLXDM==DJZCLXDM}">
<option value="${info.DJZCLXDM}" selected="selected">
${info.DJZCLXMC}
</option>
</c:if>
<c:if test="${info.DJZCLXDM!=DJZCLXDM}">
<option value="${info.DJZCLXDM}">
${info.DJZCLXMC}
</option>
</c:if>
</c:forEach>
</select>
</td>
<td>
国家标准行业:
</td>
<td>
<select name="GJBZHYDM">
<c:choose>
<c:when test="${GJBZHYDM==null||GJBZHYDM==''}">
<option value="" selected="selected">
</option>
</c:when>
<c:otherwise>
<option value="">
</option>
</c:otherwise>
</c:choose>
<c:forEach items="${gjbzhyInfoList}" var="info">
<c:if test="${info.GJBZHYDM==GJBZHYDM}">
<option value="${info.GJBZHYDM}" selected="selected">
${info.GJBZHYMC}
</option>
</c:if>
<c:if test="${info.GJBZHYDM!=GJBZHYDM}">
<option value="${info.GJBZHYDM}">
${info.GJBZHYMC}
</option>
</c:if>
</c:forEach>
</select>
</td>
<td>
<input type="button"
value="查 询"
οnclick="qry()" class="button01">
</td>
<td>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="10"></td>
</tr>
<tr>
<td>
<table width="98%" align="center" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td>
<iframe style="width: 100%" frameborder=0 name="listFrame"
id="listFrame" src="<%=path%>/back.jsp" scrolling="no"></iframe>
</td>
</tr>
</table>
<input type="hidden" name="SYSMKBH" value="${SYSMKBH }" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
<script language="javascript" type="text/javascript">
//查询
function qry(){
document.formCondition.submit();
}
</script>
</html>
注意:页面导入的库,这个版本的下拉框架样式,在ie中存在问题,最好去下载新版本的。
java后台得到jsp提交的多选数据:
String [] positions= getRequest().getParameterValues("POSITION");