Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
函数循环内的jquery函数_Jquery_Sqlite_Loops - Fatal编程技术网

函数循环内的jquery函数

函数循环内的jquery函数,jquery,sqlite,loops,Jquery,Sqlite,Loops,嗨,我在移动应用程序中,我有以下问题 我想为表billpayments中的每个条形码从表bill中选择数据 这是我的密码 t.executeSql('SELECT barcode, amount, receiptno FROM billpayments WHERE receiptno > 0', [], function(t, resultcollect) { len = resultcollect.rows.len

嗨,我在移动应用程序中,我有以下问题

我想为表billpayments中的每个条形码从表bill中选择数据

这是我的密码

        t.executeSql('SELECT barcode, amount, receiptno FROM billpayments WHERE receiptno > 0', 
            [], function(t, resultcollect) {
                len = resultcollect.rows.length;

                    for (i = 0; i < len; i += 1) {
                        row = resultcollect.rows.item(i);
                        t.executeSql('SELECT barcode, buildingcode, flatdescription FROM bill WHERE barcode = ?', 
                            [row.barcode], function(t, collectaddress) {
                                mybill = collectaddress.rows.item(0);
                                list.append('' + mybill.buildingcode + ',' + mybill.flatdescription + ',' + row.receiptno + ',' + row.amount + '</br>');
                        });


                    }
                    tameio = tameio.toFixed(2);
                    list.append('<table border="1">' + items.join('\n') + itemspay.join('\n') + '</table><p>' + tameio + '');
            });
t.executeSql('从billpayments中选择条形码、金额、收款号,其中收款号>0',
[],函数(t,resultcollect){
len=resultcollect.rows.length;
对于(i=0;i”);
});
}
tameio=tameio.toFixed(2);
list.append(''+items.join('\n')+itemspay.join('\n')+''+tameio+'');
});
但在html append中,我收到所有条形码的row.receiptno和row.amount的最后一个值


请帮助我。在迭代过程中,
行被一次又一次地覆盖。要解决此问题,请使用辅助函数创建一个新的作用域,其中
是一个局部变量:

function dummy(i) {
    var row = resultcollect.rows.item(i);             // <-- Local variable
    t.executeSql('SELECT barcode, buildingcode, flatdescription FROM bill WHERE barcode = ?', 
        [row.barcode], function(t, collectaddress) {
            var mybill = collectaddress.rows.item(0); // <-- LOCAL variable!
            list.append(mybill.buildingcode + ',' + mybill.flatdescription
                         + ',' + row.receiptno + ',' + row.amount + '</br>');
    });
}
for (i = 0; i < len; i += 1) {
    dummy(i);
}
功能虚拟(i){

var row=resultcollect.rows.item(i);/@user1081978这是一个常见的错误。我希望您已经学会不再这样做;)