Having trouble changing the value of "invocation_num" within a loop? I attempted to modify it as follows, but ended up with an undefined value. Any help would be greatly appreciated.
$(document).on("click", '.favoret', function(){
document.location.href='#favoretList';
var invocation_num = 0;
$('#favoret_table').html('');
itemsDb.transaction(function(transaction) {
transaction.executeSql('SELECT * FROM favoret GROUP BY title_id', [] , function(transaction, results) {
$.each(results.rows, function(key, value) {
var title_count;
for ( var i =0; i < title_obj.length; i++){
if(title_obj[i]['id'] == results.rows.item(key).title_id ){
itemsDb.transaction(function(transaction,invocation_num) {
transaction.executeSql('SELECT * FROM favoret', [], function(transaction, results) {
$.each(results.rows, function(key, value) {
if(title_obj[i]['id'] == results.rows.item(key).title_id){
console.log(results.rows.item(key).title_id);
invocation_num++;
}
});
});
});
$('#favoret_table').append('<tr class="list-row2 go-invoice" id="'+title_obj[i]['id']+'"><td width="100%" class="middle left-border"><span class="black" style="font-family:Nilland; font-size:17px ; font-weight:200;line-height:1rem">'+title_obj[i]['title']+' ('+get_count(title_obj[i]['id'])+') </span></td><td class="middle"><span class="icon arrow orang2"></span></td></tr>');
break;
}
}
});
});
});
// alert(favoret_title);
});
I attempted to encapsulate it in a function, but unfortunately, that didn't resolve the issue either.