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?
I think
db.transactionmight run asynchronously so that might be messing it up for you. Have you tried to move your for loop inside the transaction?