I'm also new to HTML5 , my first question concern the way transaction can be use to return result to main process.
I have tried two different ways without success. The first one is by returning value(s) and the second by the affectation a global variable.
This part of thecode will explain better:(don't blame me about the way I wrote the SQL query, I know this is a securty issue, I'll deal with it later on)
- Code: Select all
function singleHandler(transaction, results, dest_ID) {
var mydest = document.getElementById(dest_ID);
mydest.style.display = "block";
// Handle the results
if (!results.rows.length) {
mydest.innerHTML="No result found ...";
}
else{
var string = "<b>";
for (var i=0; i<results.rows.length; i++) {
var row = results.rows.item(i);
string = string + row['Nom'];
}
mydest.innerHTML=string;
window.Ref = row['Ref'];
}
}
function Query_Single_Data(db, table, field, value, dest_ID){
db.transaction(
function (transaction) {
transaction.executeSql("SELECT * from " + table + " WHERE " + field + " LIKE '" + value + "';", [], function(transaction, results) {
singleHandler(transaction, results, dest_ID);
}, errorHandler);
}
);
}
The trouble is Ref is not correctly affected. It looks like it takes time to exécute this affectation.
When I submit the form to fire the transaction it return the value of the declation of window.Ref. But if I submit again, the value is affected.
I'm probably doing something wrong ?
I hope this is clear enough