My first time attempt to update a field in record, but, its not saving update when using a variable to specify the row.
Issue background – When the user clicks on an image, the checkDone() function is called, passing the row number (i). I then set a global variable (glbID) to the row nbr (i), and called the updateDB function to update the status field for the specified row. I never received an error, but, noticed the field was not updating. When I hardcoded the row id it saved the update. But, using the glbID var, as well as another strID to see if it was a format type issue, could not resolve the issue. Have tried several other variations to no avail.
Appreciate any one’s help on this. Am testing with Android emulator, let me know if any other info helpful for analysis.
function checkDone(i) {
var db = window.openDatabase("Database", "1.0", "GTKdb", 200000);
glbID = i //SET global variable to row nbr
document.getElementsByTagName("img")[i].src = "img/checkbox_checked.png";
db.transaction(updateDB, errorCB);
}
function updateDB(u) {
var strDone = "DONE"
var strID = "" + glbID; //SET new variable to glbID, converting to string to see if format type issue
u.executeSql('UPDATE USER set status = ? where id = ?', [strDone,"2"], successCB, errorCB); //THIS WORKS WHEN ID value hardcoded
//u.executeSql('UPDATE USER set status = ? where id = ?', [strDone,glbID], successCB, errorCB); //NO UPDATE using var glbID
//u.executeSql('UPDATE USER set status = ? where id = ?', strDone,strID], successCB, errorCB); //NO UPDATE using var strID
alert('AFTER UPDATE Status= '+status); //No value for status appears
}
I’m not sure, but this might be the problem. when you are inserting string you need to give it inside quotes.
hope it helps.