<span style="font-size:18px;"><span style="white-space:pre"> </span><tr> <td height="32px" width="150px" align="center" bgcolor="#eaf8ff">机构编号</td> <td> <input type="text" name="" id="" size="40" onblur="getJgmc(this.value)"/> <input type="hidden" name="nlyz.jdjg_id" id="jdjg_id"/> </td> </tr></span>javaScrip代码段
function getJgmc(xkzh){ $.ajax({ method : "POST",url : "jdjg/jdjg_getJgmcByXkzh.do",data : "xkzh="+xkzh,dataType : "json",cache : false,error : function() { alert("请求失败"); },success : function(data) { var jgmc = data.jgmc; var jdjg_id = data.jdjg_id; var xzqy = data.xzqy; if(jgmc == "null"){ alert("无对应机构,请核准机构编号!"); }else{ document.getElementById("jgmc").value = jgmc; document.getElementById("jdjg_id").value = jdjg_id; document.getElementById("xzqy").value = xzqy; } } });
后台数据传输实现
public void getJgmcByXkzh() throws IOException { jdjg = jdjgService.getJgmcByXkzh(request.getParameter("xkzh")); response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); JSONObject jo = new JSONObject(); if (jdjg!=null) { jo.put("jgmc",jdjg.getJg_jgmc()); jo.put("jdjg_id",jdjg.getId()); jo.put("xzqy",jdjg.getJg_xzqy()); }else { jo.put("jgmc","null"); } out.print(jo); out.flush(); out.close(); }