jquery为下拉框添加option
前台:
function load_allemployees(employee_type){
var url = "onLoadEmployee.do";
var p_data = "employee_type=" + employee_type;
doAjaxSubmit(url, p_data, filSelect);
}
function filSelect(data){
$("#left_").empty();
var employeeArr = document.getElementById('left_');
for(var i=0;i<data.length;i++)
{
var op = document.createElement("OPTION");
op.value = data[i].user_id;
op.innerHTML =data[i].user_name;
employeeArr.appendChild(op);
}
}
function doAjaxSubmit(p_url, p_data, p_callback) {
$.ajax({
type:"POST",
url: p_url,
data: p_data,
dataType:"json",
success: function(data){
p_callback(data);
}
});
}
[html]
后台:
package com.aegon_cnooc.oa.admin.action;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONSerializer;
import net.sf.json.util.JSONUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>