Only the last run in a for loop in Javascript works
- by Mengfei Murphy
Here is a for loop written by Javascript. It is trying to apply queries for websql.
for (var i = 0; i < 10; i++){
db.transaction(function (tx){
tx.executeSql('INSERT INTO ProjSetsT (ProjID) VALUES (?);', [i]);
});
}
The attempt is obvious, I tried to add values "0, 1, 2, ... 9" into column ProjID in table ProjSetsT. It does not work. I only got the last element, i.e. "9" inserted, but not the first eight numbers.
Is there any syntax mistakes?