<script type="text/javascript">
$(function() {
customPayOtherAccountList= new Array();//创建对象的数组
});
function addData(){
var customPayOtherAccount=new Object()
var otherTable =$("#otherTable .form-control");
var otherDetailTableIdAndVal = otherTable.map(function(){
eval('('+"customPayOtherAccount."+this.id+"="+this.value+')');//missing ;
})
customPayOtherAccountList.push(customPayOtherAccount);//将对象添加到数组中去
//console.log(customPayOtherAccountList);
var otherDetailTable =$("#otherDetailTable thead tr th");
var otherDetailTableThIdIndex = otherDetailTable.map(function(){
return $(this).find("[type='hidden']").val();
})
var addIndex=$("#otherDetailTable tbody tr").length;
var addStr="<tr>";
addStr = addStr+"<td align='center'><input type='checkbox' name='detailNo'></td>";
$.each(otherDetailTableThIdIndex, function(index, value) {
addStr=addStr+"<td>"+eval("customPayOtherAccount."+value)+"</td>";
});
addStr = addStr+"</tr>";
$("#otherDetailTable tbody").append(addStr);
let arr = JSON.stringify(customPayOtherAccountList);
console.log(customPayOtherAccountList);
$("#customPayOtherAccountList").val(arr);
}
</script>
JavaScript练习
最新推荐文章于 2024-05-14 23:26:36 发布