I'm a bit of an newbie in this - I've been trying for a couple of days to modify various stackoverflow answers without any luck at all.
For my phonegap app - using sqlite, jquery I'm trying to loop through a category table, then have a nested list of 'kinds' for each category. The code below produces the outer loop, but not the inner.
Any help would be very much appreciated
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM cat;', [], function (transaction, catResult) {
var theHtml ='';
for (var i = 0; i < catResult.rows.length; i++) {
// outer loop
var catRow =catResult.rows.item(i);
theHtml +='<li>' +catRow.Name;
function doinner(i) {
var theHtml2 ='';
tx.executeSql('SELECT * FROM kind WHERE cat_id = ?;', [catRow.Id], function (transaction, kindResult) {
theHtml2 ='<ul>';
for (var i2 = 0; i2 < kindResult.rows.length; i2++) {
// inner loop
var kindRow =kindResult.rows.item(i2);
theHtml2 +='<li>' +kindRow.kind +'</li>';
};
// end inner loop
theHtml2 +='</ul>';
});
// end function
theHtml +=theHtml2;
}
// end doinner
doinner(i) ;
// this function is supposed to assemble and append the inner loop
theHtml +='</li>';
}
// end outer loop
$('#catList').html(theHtml);
});
// end function
});
// end transaction