You can also do:
db.transaction(function(tx) { tx.executeSql("INSERT INTO project (cd, pn) VALUES (?,?)", cast, function(tx, res) { var id = res.insertId; }); });
Thus, getting the result of a successful insert, and then its insertId property
source share