考虑:
var globalvar;
function viewyearmain() {
db.transaction(function (tx)
{
tx.executeSql('SELECT * FROM BUDGET WHERE holdingtype="month"', [], function (tx, results)
{
var len = results.rows.length;
msg = len;
globalvar = msg;
}, null);
});
if (globalvar>0)
{
alert("ROWS FOUND");
}
else
{
alert("ROWS NOT FOUND");
}
}
出现问题是因为在到达语句ROWS NOT FOUND
时事务尚未完成。if