zoukankan      html  css  js  c++  java
  • Ajax+json实现菜单动态级联

    1:jsp

    //级联ajax处理函数

     function areaChange(){
        var areano=document.all("areaNo").value;
        var url="${pageContext.request.contextPath}/infoAction.do?method=queryPeopleByPosition";
          $.post(url,{areaNo:areano,position:"200"},
            function(personList){ 
                  var personList=personList.personList; 
                  $("#businessManager").empty();//删除所有option选项
                  document.all("businessManager").options.add(new Option('-请选择-',''));
                  for(var p in personList){
                     document.all("businessManager").options.add(new Option(personList[p],personList[p]));
                  }               
            },"json");
        }

    <td>地区</td>
    <td>
           <html:select property="areaNo" style=" 80px" onchange="areaChange()">
                  <html:option value="">-请选择-</html:option>
                  <c:forEach items="${listArea }" var="i">
                   <html:option value="${i.nodeNo }">${i.nodeName }</html:option>
                  </c:forEach>
                 </html:select>
    </td>
    <td>业务经理</td>
    <td>
                 <html:select property="businessManager" styleId="businessManager" style=" 80px">
                  <html:option value="">-请选择-</html:option>
                  <c:forEach items="${teamList}" var="i">
                   <html:option value="${i.staffName }">${i.staffName }</html:option>
                  </c:forEach>
                 </html:select>
    </td>

    2、java处理方法

    //查询根据地区动态查询对应职级人员信息(动态级联使用)
     public ActionForward queryPeopleByPosition(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{
      try {
       String areaNo=request.getParameter("areaNo");
       String position=request.getParameter("position");
       P2pStaffInfo queryParams = new StaffInfo();
          queryParams.setAreaNo(areaNo);// 地区
          queryParams.setPosition(position);//

          List<StaffInfo> personJavaList = infoLogic.queryStaffInfo(queryParams);

       JSONObject personList=new JSONObject();
       JSONObject person=new JSONObject();
       if (null!=personJavaList&&personJavaList.size()>0) {
        for (P2pStaffInfo po:personJavaList) {
         person.put(po.getStaffName(), po.getStaffName());
        }
       }
       personList.put("personList", person);
       response.setCharacterEncoding("gbk");
       PrintWriter pw=response.getWriter();
       pw.write(personList.toString());
       pw.flush();
       pw.close();
      } catch (Exception e) {
       log.error("根据职级动态级联地区查询出错!", e);
       e.printStackTrace();
      }
      return null;
     }

  • 相关阅读:
    android switch控件的使用
    触摸屏校准tslib的配置文件
    matlab 函数的编写与调用
    penmount串口触摸屏加载
    FPGA保留信号的语句
    ioctl和unlock_ioctl的区别
    内核目录中增加自己的目录
    linux内核打印"BUG: scheduling while atomic
    28335外部中断
    编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
  • 原文地址:https://www.cnblogs.com/Defry/p/4650704.html
Copyright © 2011-2022 走看看