我在移动应用程序,我想用复选框的值填充数组。jquery如何填充数组
我的代码是
if (row.flatdescription == flatdescription) {
if (row.receiptno == 0){
items.push('<input type="checkbox" name="code_'+ i +'" id="code_'+ i +'" value="' + row.amount + '" previous="' + row.pastpayments + '" barcode="' + row.barcode + '" todayp="' + row.todaypayments + '"/><label for="code_'+ i +'">' + row.period +'..........'+ row.amount+'</label></br>');
}
allbarcode[i] = row.barcode;
previouspayments1 = previouspayments1 + row.pastpayments;
previouspayments = previouspayments1.toFixed(2);
sofeilon1 = sofeilon1 + row.amount;
sofeilon = sofeilon1.toFixed(2);
total1 = total1 + row.amount - row.pastpayments;
total = total1.toFixed(2);
}
和我的阵列码
function barcodeTotal() {
barcode = [];
barcodeamount = [];
barcodeprevious = [];
$("input:checked").each(function(i) {
barcode[i] = $(this).attr("barcode");
barcodeamount[i] = $(this).attr("value");
barcodeprevious[i] = $(this).attr("previous");
});
}
我的目标是填补条形码阵列这样
barcode [barcode: barcode, amount: value, previous: previous, ....
我会感谢你的答案
我使所建议的修改,但我收到警报[对象的对象],[对象的对象] function barcodeTotal(){ \t \t \t \t var self = this; \t \t \t \t var barcodes = []; \t \t \t \t $( “输入:勾选”)。每个(函数(I,项目){ \t \t \t \t \t barcodes.push({ \t \t \t \t \t \t条码:$(个体经营).attr( “条形码”), \t \t \t \t \t \t金额:$(个体经营).attr( “值”), \t \t \t \t \t \t前一个:$(self).attr(“previous”) \t \t \t \t \t}); \t \t \t \t \t // barcode [i] = $(this).attr(“barcode”); \t \t \t \t \t // barcodeamount [i] = $(this).attr(“value”); \t \t \t \t \t // barcodeprevious [i] = $(this).attr(“previous”); \t \t \t}); 提醒(条形码); \t \t \t} – kosbou 2012-02-11 08:02:00