These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:03 pm Advanced search

transaction and global variables

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

transaction and global variables

Postby riete » Tue Aug 24, 2010 3:47 pm

Hi there! I'm new to this forum and hope that this will be a long term cooperation.

I'm also new to HTML5 :wink:, 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 mydest block is well affected, but I would like to avoid this way of modifying the content of the page. I would prefer to modify the global variable Ref.
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
riete
<h6>
 
Posts: 1
Joined: Tue Aug 24, 2010 3:28 pm

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest