0
When I load the page even the function getChamadasFromDay() starting after loading the variables total_time and total_calls continue with the value zero.
note that the variable total_time and total calls are receiving values but for some reason continue as 0 Zero.
If you make a console.log(results.row.item(i).d_time)
it prints the values in the console.
I need that when loading the page get all the values of WEBSQL and make a calculation to be informed on the screen.
var total_time = 0;
var total_chamadas = 0;
window.addEventListener('load',function(){initDB()},false);
function initDB(){
db = openDatabase (database_name, database_version, database_description, database_size);
if(!db){
alert('Erro Navegador nao possui suporte ao WebSQL.')
}
else{
getChamadasFromDay();
}
}
function getChamadasFromDay(){
db.transaction (function (tx) {
tx.executeSql ('SELECT * FROM chamadas WHERE d_day=? AND d_month=? AND d_year=?', [
data.getDate(),
data.getMonth(),
data.getFullYear()
], function (tx, results) {
var len = results.rows.length;
for (i = 0; i <len; i ++) {
total_time += parseInt(results.rows.item(i).d_time);
total_chamadas++;
}
}, null);
});
}