>I am working on a web page that will be used to update on-hand quantity of parts in a stock room. The page is very simple: it has a text box Part No and a text box Quantity. The user will scan or type in the Part No text box and then enter the current on-hand quantity in the Quantity box. Then user clicks on Submit button. Submit button will call a stored procedure that will update the database table(s).
>
>The program will work in a company Wi-Fi. But it is possible that for a short period (or maybe longer) the Wi-Fi signal will be dropped. So, if the connection is dropped, - ideally - (I would need to check it before calling the stored procedure) I would store the values in the Local Storage. Then, when connection is restored the data from the Local Storage should be processed (transparent to the user).
>
>How could this be done, conceptually? That is, how would a program/page call a stored procedure for every pair of values in the Local Storage?
>TIA
Something like:
saveEntry(partno, quan) {
var entry = { PartNo: partno, Quan: quan };
if (localStorage['entries'] === undefined) {
var entries = new Array;
} else {
entries = JSON.parse(localStorage['entries']);
}
entries.push(entry);
localStorage['entries'] = JSON.stringify(entries);
if (window.navigator.onLine) {
localStorage['entries'] = JSON.stringify(new Array);
}
}
This would send when a new entry was added. If you wanted to send when a connection became available you could add a watch on window.navigator.online and send from there....