日期:2014-05-16 浏览次数:20689 次
接收部门:<select name="dept" style="width:100px" id="dept">
<s:iterator id="list" var="list" value="list">
<option value="<s:property value='id'/>"><s:property value="name"/></option></s:iterator>
</select>
接收人员:<select name="opeUserCode" id="opeUserCode">
</select>
$("#dept").change(
function() {
$.ajax({
type : "post",//使用get方法访问后台
dataType : "json",//返回text格式的数据
url : "hlb_getDeptUser.action",//要访问的后台地址
data : "dept="+ $("#dept").val(),//要发送的数据
async : true,
/*complete : function(data) { },*/
success : function(data) { //msg为返回的数据,在这里做数据绑定
var userId;
var userName;
$(data,function(i) {
var sj = data[i];
userId = sj[0];
userName = sj[1];
$("#opeUserCode").append(
"<option value='"+userId+"'>"+userName+"</option>"
);
});
}
});
});
Connection conn = ConnectionManager.getDssConn();
DBManager dbManager = new DBManager(conn);
ResultSet rs = null;
String sql = "";
List list = new ArrayList();
try {
sql = "select dept_id,dept_name from env_t_department where zt=1";
rs = dbManager.sqlSelect(sql);
while(rs.next()){
DeptObject obj = new DeptObject();
obj.setId(rs.getString("dept_id"));
obj.setName(rs.getString("dept_name"));
list.add(obj);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
ConnectionManager.closeConn(conn);
}
response.setCharacterEncoding("utf-8");
try {
response.getWriter().write(JsonUtil.list2json(list));
} catch (IOException e) {
e.printStackTrace();
}