select二级联动
来源:互联网 发布:软件开发行业分析 编辑:程序博客网 时间:2024/04/29 13:04
jquery ajax
<!-- 归属地联动 --><script type='text/javascript' src='<%=request.getContextPath() %>/js/jquery.js'></script><script type='text/javascript'>$(document).ready(function() { $("#ownerAddress").change( function(){ $.ajax({type : "POST",dataType : "json", url :"<%=request.getContextPath()%>/queryOwnerAddress.jspx?ownerAddress="+document.getElementById('ownerAddress').value,success : function(result){$("#ownerAddressNode option").remove();$("#ownerAddressNode").append("<option>请选择</option>");if( result != null && result != "" ){for(var i=0;i<result.length;i++){$("#ownerAddressNode").append("<option value='"+result[i].id+"'>"+result[i].name+"</option>");}}}});});});</script>
java代码
/** * 查询归属地信息 * @param request * @param response * @return */@RequestMapping(value = "/queryOwnerAddress.jspx", method = RequestMethod.POST)public String queryOwnerAddress(HttpServletRequest request, HttpServletResponse response) {String ownerAddress = request.getParameter("ownerAddress");JSONArray jsonArray = clubService.queryOwnerAddress(ownerAddress);StringUtil.webCommonResponse(request, response, jsonArray);return null;}
public JSONArray queryOwnerAddress(String ownerAddress) {JSONArray jsonArray = new JSONArray();if("1".equals(ownerAddress)) {JSONObject json1 = new JSONObject();json1.put("id", 1);json1.put("name", "苏州市区");jsonArray.add(json1);JSONObject json2 = new JSONObject();json2.put("id", 2);json2.put("name", "苏州郊区");jsonArray.add(json2);}if("2".equals(ownerAddress)) {JSONObject json1 = new JSONObject();json1.put("id", 1);json1.put("name", "南京市区");jsonArray.add(json1);JSONObject json2 = new JSONObject();json2.put("id", 2);json2.put("name", "南京郊区");jsonArray.add(json2);JSONObject json3 = new JSONObject();json3.put("id", 3);json3.put("name", "其它地区");jsonArray.add(json3);}return jsonArray;}
public static void webCommonResponse(HttpServletRequest req, HttpServletResponse rsp, Object json) {rsp.setContentType("text/html; charset=UTF-8");rsp.setCharacterEncoding("UTF-8");rsp.setHeader("Cache-Control", "no-cache");String encoding = req.getHeader("Accept-Encoding");if (encoding != null && encoding.indexOf("gzip") != -1) {rsp.setHeader("Content-Encoding", "gzip");GZIPOutputStream out = null;try {out = new GZIPOutputStream(rsp.getOutputStream());out.write(json.toString().getBytes("UTF-8"));}catch (IOException e) {// LOGGER.error("", e);}finally {try {out.flush();out.finish();out.close();}catch (IOException e) {// LOGGER.error("", e);}}return;}try {rsp.getWriter().println(json.toString());rsp.getWriter().flush();}catch (IOException e) {// LOGGER.error("", e);}}
- select二级联动
- select二级联动
- <s:select>二级联动
- 二级联动Select标签
- 简易select二级联动
- select二级联动
- 二级联动select
- select 二级联动
- select select二级联动效果
- select菜单实现二级联动
- ligerui实现select二级联动
- js之select二级联动
- jquery实现select二级联动
- web 中的select二级联动
- 多个select联动(省市二级联动)
- 利用XMLHTTP实现的二级联动Select
- JQuery实现二级 select框联动选择
- JS+html 实现select二级联动菜单
- opencv一些函数的底层代码
- Android JNI实例代码(二)
- Simple iOS 5 UI Design Tutorial Using Storyboard in XCode 4
- c++ 前置声明不能随便用 会引起类型不完全的错误
- Android 查看内存使用情况
- select二级联动
- 产品各类型之间的关系
- Android开发进阶(七)-- Android客户端访问PHP服务器的详细过程
- 泛型算法总结
- 标准炮灰三人组飞鸽传书武侠片
- CX51 用户手册----INCDIR 伪指令
- RFC3581-关于rport字段 的阅读笔记(一)
- Fedora14 源码安装qt4.7.0 PC版 和 arm版 过程 及问题解决
- Redhat 6 恢复boot分区