In my page I have different buttons and when each clicked it will generate different queries to access database. I already had one function “queryDB” to retrive all the data in the table and when I click the reset button, another query to UPDATE the table values.
I notice it DID NOT went into the FUNCTION “resetDB“. Is it because phoneGap use “queryDB” function only? How should I solve this?
***New found problem**
I realise when I use location.reload() it will not update the table. So I didnt use it, it did go into the function and update the database but it did not show the “new”page. If I use href back to the settings page, it will not update the database like before.
$('button#reset').on("click",function(){
var db = window.openDatabase("Database", "1.0", "ApplicationDB", 200000);
db.transaction(resetDB, errorCB);
location.reload();
});
Function resetDB
function resetDB(tx) {
tx.executeSql("UPDATE RESULT SET Difficulty = 'Easy' " , [], querySuccess, errorCB);
}
Function queryDB
function queryDB(tx) {
tx.executeSql("SELECT * FROM RESULT ORDER BY Level" , [], querySuccess, errorCB);
}
I believe this should work for you.