I have a bookid and i need to pass it on sqlite transaction in cordova
like
var bookName = db.transaction(function(tx){
return tx.executeSql('SELECT * FROM Iqra_Book WHERE book_id=?',[1],function(tx,res){
var leng = res.rows.length;
console.log("Length: " + leng);
return bkName = res.rows.item(0).book_name;
}
, function(e) {
return console.log("ERROR: " + e.message);
});
});
But I am getting this booName as undefined.
Can anyone help me out ?
you need to pass a variable to the book id. leave away the “return”, you cant just return a value since the web database works asynchrounously
also, change the line
to
and check if it works