I have a simple function to count the number of rows in a database and return the result. However I am getting the result returned as undefined, even though if I console.log the result it is coming up correctly from within the function. Here is the gist of what I am doing although I have stripped out a lot of code to simplify it.
$('#roomsList').append(getCount(currentRow.roomtype));
function getCount(roomtype) {
var query = "SELECT COUNT(*) FROM fixturesfittings WHERE roomtype = ?;"
localDatabase.transaction(function(trxn) {
trxn.executeSql(query, [propertyid, roomtype], function(transaction, results) {
return results.rows.item(0)["COUNT(*)"];
}, errorHandler);
});
}
Can anyone help me?