<!--回车进入页面-->
function enter(){
if(window.event.keyCode == 13)
{ var workcode = $F('workcode');
var url = '/HrmResourceAdd1.jsp';
var pars = 'workcode=' + workcode;
var myAjax = new Ajax.Request(url, {method: 'get', parameters: pars, onComplete: showResponse});
}
}
function showResponse(originalRequest) {
var resText = originalRequest.responseText.evalJSON();
$('lastname').value = resText.personInfo[0].lastname;
$('telephone').value = resText.personInfo[0].telephone;
$('mobile').value = resText.personInfo[0].mobile;
}
HrmResourceAdd1.jsp
<%@ page language="java" pageEncoding="GB2312"%>
<%@page import="org.json.JSONArray"%>
<%@page import="org.json.JSONObject"%>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page"/>
<%
String workcode = request.getParameter("workcode");
//根据workcode取数据库信息 得到结果集
JSONArray jsonList = new JSONArray();//
JSONObject obj = new JSONObject();//
String sql="select * from employee se where se.badge='"+workcode+"'";
RecordSet.executeSql(sql);
//循环
while(RecordSet.next()){
obj.put("workcode",RecordSet.getString("badge"));
obj.put("lastname",RecordSet.getString("name"));
obj.put("telephone",RecordSet.getString("OFFICEPHONE"));
obj.put("mobile",RecordSet.getString("mobile"));
obj.put("fax",RecordSet.getString("telephone"));
obj.put("email",RecordSet.getString("email"));
jsonList.put(obj);//
}
//循环结束
JSONObject json = new JSONObject();
json.put("personInfo", jsonList);
//response.setHeader("X-JSON", json.toString());
response.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control", "no-cache");// 清楚缓存
response.getWriter().print(json.toString());
%>
function enter(){
if(window.event.keyCode == 13)
{ var workcode = $F('workcode');
var url = '/HrmResourceAdd1.jsp';
var pars = 'workcode=' + workcode;
var myAjax = new Ajax.Request(url, {method: 'get', parameters: pars, onComplete: showResponse});
}
}
function showResponse(originalRequest) {
var resText = originalRequest.responseText.evalJSON();
$('lastname').value = resText.personInfo[0].lastname;
$('telephone').value = resText.personInfo[0].telephone;
$('mobile').value = resText.personInfo[0].mobile;
}
HrmResourceAdd1.jsp
<%@ page language="java" pageEncoding="GB2312"%>
<%@page import="org.json.JSONArray"%>
<%@page import="org.json.JSONObject"%>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page"/>
<%
String workcode = request.getParameter("workcode");
//根据workcode取数据库信息 得到结果集
JSONArray jsonList = new JSONArray();//
JSONObject obj = new JSONObject();//
String sql="select * from employee se where se.badge='"+workcode+"'";
RecordSet.executeSql(sql);
//循环
while(RecordSet.next()){
obj.put("workcode",RecordSet.getString("badge"));
obj.put("lastname",RecordSet.getString("name"));
obj.put("telephone",RecordSet.getString("OFFICEPHONE"));
obj.put("mobile",RecordSet.getString("mobile"));
obj.put("fax",RecordSet.getString("telephone"));
obj.put("email",RecordSet.getString("email"));
jsonList.put(obj);//
}
//循环结束
JSONObject json = new JSONObject();
json.put("personInfo", jsonList);
//response.setHeader("X-JSON", json.toString());
response.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control", "no-cache");// 清楚缓存
response.getWriter().print(json.toString());
%>