根據(jù)ID填充文本框的實例代碼
更新時間:2013年07月03日 15:30:00 作者:
這篇文章介紹了根據(jù)ID填充文本框的小例子,有需要的朋友可以參考一下
前臺:
<script type="text/javascript">
function func_load_remark(sr_id){
if(sr_id!=0){
$.getJSON("loadSrRemark.do?date="+new Date(), {srid:sr_id}, function(srmain){
$("#bparemark").val(srmain.bpa_remark);
$("#itdremark").val(srmain.itd_remark);
$("#bugremark").val(srmain.bu_remark);
$("#itoremark").val(srmain.ito_remark);
});
}else{
$("#bparemark").val("");
$("#itdremark").val("");
$("#bugremark").val("");
$("#itoremark").val("");
}
}
function check(){
if($("#srid").val()=="0"){
alert("請選擇SR_ID!");
$("#srid").focus();
return false;
}
return true;
}
</script>
后臺:
package com.aegon_cnooc.oa.admin.action;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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;
import com.aegon_cnooc.framework.base.action.BaseAction;
import com.aegon_cnooc.oa.admin.service.UserService;
import com.aegon_cnooc.oa.ibatis.to.TuOafSrMainTO;
public class LoadSrRemarkAction extends BaseAction{
private UserService userService;
public ActionForward executeAction(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String srid=request.getParameter("srid");
TuOafSrMainTO srMain=userService.getRemarkBySrId(srid);
response.setContentType("application/json;charset=gbk");
response.setCharacterEncoding("gbk");
PrintWriter pw = response.getWriter();
pw.write(JSONUtils.valueToString(JSONSerializer.toJSON(srMain)));
pw.flush();
return null;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
}
復(fù)制代碼 代碼如下:
<script type="text/javascript">
function func_load_remark(sr_id){
if(sr_id!=0){
$.getJSON("loadSrRemark.do?date="+new Date(), {srid:sr_id}, function(srmain){
$("#bparemark").val(srmain.bpa_remark);
$("#itdremark").val(srmain.itd_remark);
$("#bugremark").val(srmain.bu_remark);
$("#itoremark").val(srmain.ito_remark);
});
}else{
$("#bparemark").val("");
$("#itdremark").val("");
$("#bugremark").val("");
$("#itoremark").val("");
}
}
function check(){
if($("#srid").val()=="0"){
alert("請選擇SR_ID!");
$("#srid").focus();
return false;
}
return true;
}
</script>
后臺:
復(fù)制代碼 代碼如下:
package com.aegon_cnooc.oa.admin.action;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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;
import com.aegon_cnooc.framework.base.action.BaseAction;
import com.aegon_cnooc.oa.admin.service.UserService;
import com.aegon_cnooc.oa.ibatis.to.TuOafSrMainTO;
public class LoadSrRemarkAction extends BaseAction{
private UserService userService;
public ActionForward executeAction(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String srid=request.getParameter("srid");
TuOafSrMainTO srMain=userService.getRemarkBySrId(srid);
response.setContentType("application/json;charset=gbk");
response.setCharacterEncoding("gbk");
PrintWriter pw = response.getWriter();
pw.write(JSONUtils.valueToString(JSONSerializer.toJSON(srMain)));
pw.flush();
return null;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
}
相關(guān)文章
Spring之InitializingBean接口和DisposableBean接口的使用
這篇文章主要介紹了Spring之InitializingBean接口和DisposableBean接口的使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-01-01