form表單,轉Map,轉List
阿新 • • 發佈:2018-12-18
1、form表單包含,select下拉列表,input輸入框等,轉為Map,js如下:
var baseInfo = {};
var formArray =$("#baseInfo").serializeArray();
$.each(formArray,function(i,item){
baseInfo[item.name] = item.value;
});
注:$("#baseInfo"),baseInfo是form的id
2、form表單包含,select下拉列表,input輸入框等,轉為List<Map>,js如下:
var workInfoArr=[];
$("#workContent form").each(function(){
var formObject01 = {};
var formArray01 =$(this).serializeArray()
$.each(formArray01,function(i,item){
formObject01[item.name] = item.value;
});
workInfoArr.push(formObject01);
})
注:$("#workContent form")