Q:

i = Undefined in a function who is in a function

In the function "Encaisser", the value of "i" is OK in the for, but if i call 'i' in a function in my function, "i" return "Undefined. 
function Encaisser()
{

   for(var i=1; i <= Nombre_ligne_en_caisse; i++)
   {    
      db.transaction(function(t,i){ t.executeSql('SELECT En_cour FROM Sequence WHERE Nom="Ticket_ID"', [], function(tx,rs,i){ 

         var row = rs.rows.item(0); 
         var Tick_ID = row['En_Cour']; 
         var Noma = window['Produit_en_caisse_' + i]  ;

         alert(i); //Undefined
         alert(Noma); //Undefined

      }, [])});
   alert(i); //If i put the alert here, its OK
   }

}

Do you know why? 
Thank You,

A:

The problem is that your inner function defines a parameter named i here:
db.transaction(function(t,i){ ...

If you intend for i to be the value from the outer function, I recommend you simply remove this parameter.  It doesn't appear that db.transaction is actually providing a value for this parameter anyway.  You'll probably also want to close the value of i at each iteration in a separate variable, and use that inside your function, like this:
var index = i;
db.transaction(function(t){ ...

     var Noma = window['Produit_en_caisse_' + index ];

     alert(index);

