Skip to content

Instantly share code, notes, and snippets.

@glynrob
Created January 27, 2013 12:19
Show Gist options
  • Save glynrob/4648124 to your computer and use it in GitHub Desktop.
Save glynrob/4648124 to your computer and use it in GitHub Desktop.
WebSQL Load saved data
// get the locally saved data
function loadSavedData(){
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM data', [], function (tx, results) {
console.log(results);
var len = results.rows.length, i;
for (i = 0; i < len; i++) {
var saveItem = {
"value": results.rows.item(i).text,
"label": results.rows.item(i).id
};
itemCount++; // increase labelname by 1
savedData.push(saveItem);
}
// don't run html display until the query has been fully executed
showListItems();// Generate the list items and display
showLocalData();// show data
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment