Posted on 2011-12-21 15:49
哈希 阅读(287)
评论(0) 编辑 收藏 所属分类:
Js and Jquery 常用总结
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
$(function(){$("#sendAddress").change(function(){
var sendAddress=$("#sendAddress").val();
getCustomerInfo(sendAddress);
});
});
//出货方信息填充
function getCustomerInfo(id){
//alert(id);
$.ajax({
type: 'get',
url: "<c:url value='/k4_oldGoldStorsge/getCustomerInfoByAddressId/'/>"+id,
dataType: 'json',
success: function(data) {
alert(data.name);
$("#supplyer").val(data.linkman);
$("#supplyIdentityCard").val(data.identification);
$("#supplyerMobile").val(data.mobile);
$("#supplyerPhone").val(data.tel);
//$("#").val(data.);
}
});
}
$(function(){$("#outStorageList").change(function(){
var outStorageList=$("#outStorageList").val();
//alert(outStorageList);
//getCustomerInfo(sendAddress);
getAddressList(outStorageList)
});
});
function getAddressList(id){
//alert(id);
$.ajax({
type: 'get',
url: "<c:url value='/k4_oldGoldStorsge/getAddressByCustomerId/'/>"+id,
dataType: 'html',
success: function(data) {
var address=eval(data);
//遍历取值
$.each(address,function(i,n){
$("#getAddress").append($("<option value='"+address[i].id+"'></option>").text(address[i].address));
});
}
});
}
$(function(){$("#getAddress").change(function(){
var sendAddress=$("#getAddress").val();
getMenInfo(sendAddress);
});
});
function getMenInfo(id){
$.ajax({
type: 'get',
url: "<c:url value='/k4_oldGoldStorsge/getCustomerInfoByAddressId/'/>"+id,
dataType: 'json',
success: function(data) {
$("#receiver").val(data.linkman);
$("#receiverIdentityCard").val(data.identification);
$("#receiverMobile").val(data.mobile);
$("#receiverPhone").val(data.tel);
//$("#").val(d
/** *//**
* 收货方ID获取地址信息
* @return
*/
public void getAddressByCustomerId(String id) {
List<Address> list=new ArrayList<Address>();
list=oldGoldStorageService.findAddressList(id);
StringBuilder json = new StringBuilder();
json.append("[");
for (int i = 0; i < list.size()-1; i++) {
json.append("{'id':'").append(list.get(i).getId()).append("',");
json.append("'address':'").append(list.get(i).getAddressDeatil()).append("'},");
}
json.append("{'id':'").append(list.get(list.size()-1).getId()).append("',");
json.append("'address':'").append(list.get(list.size()-1).getAddressDeatil()).append("'}");
json.append("]");
System.out.println(json);
this.renderJSON(json.toString());
} ata.);
}
});
}
- <script type="text/javascript">
- $(document).ready(function(){
- var url='TypeGet?d='+Math.random();
- $.get(url,
- function dedit(data){
- var m=eval(data);
- $.each(m, function(i) {
-
- $('#pselect').append('<option value="'+m[i].no+'">' + m[i].name+ '</option>');
-
- });
-
- });
- </script>
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
- request.setCharacterEncoding("UTF-8");
- response.setCharacterEncoding("UTF-8");
-
- ArrayList result=new ArrayList();
- Connection conn=null;
- Statement st=null;
- ResultSet rs=null;
-
- try{
-
- conn=DBConnection.getConnection();
- st=conn.createStatement();
- rs=st.executeQuery("select * from ddpms_devicetype order by name");
- while(rs.next()){
- DevicetypeBean dt=new DevicetypeBean();
- dt.setNo(rs.getInt("no"));
- dt.setName(rs.getString("name"));
- result.add(dt);
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- rs.close();
- st.close();
- conn.close();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- response.setContentType("text/html");
- PrintWriter out= response.getWriter();
-
- out.write(toString(result));
- }
- public String toString(ArrayList s)
- {
- String str="[";
- for(int i=0;i<s.size();i++){
- DevicetypeBean dt=(DevicetypeBean)s.get(i);
- str+="{'no':'"+dt.getNo()+"','name':'"+dt.getName()+"'},";
- }
- str=str.substring(0,str.length()-1)+"]";
- return str;
- }
$(function(){$("#logisticsDistributionBook").click(function()
{
var checkValues=getCoulmnValue(oTable, 'id');
// alert(checkValues);
var aoData = new Array();
aoData.push( { "name": "ids", "value":checkValues } );
if(isEmpty(checkValues)){
showInfo("请选择需要处理的数据行!");
return false;
}else if(!isEmpty(checkValues)){
$.ajax({
type: 'post',
url: "<c:url value='/k4_oldGoldStorsge/checkDispatchStatusId/make/1'/>",
dataType: 'json',
data: aoData,
success: function(data) {
//alert(data);
if(parseInt(data)>=1){
//alert(data);
showInfo("必须全部选择没有生成过物流配送书的数据!");
return;
}else if (checkProductId()) {
getHidVal(checkValues);
}
}
});
}
});
});
public void checkDispatchStatusId(String type, String id) {
String myid = request().getParameter("ids");
String[] ids = myid.split(",");
int count = 0;
if ("make".equals(type)) {
count = oldGoldStorageService.findNumofDispatch(myid);
}
this.printHtml(count);
}
这两篇也不错!
http://tochal.iteye.com/blog/722265
http://blog.csdn.net/huhai463127310/archive/2009/11/29/4901654.aspx