Do it the other way around:
<script> numberofArticles = 5; db = openDatabase("websql", "0.1", "web-sql testing", 10000); db.transaction(function(tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, articleID int)'); }); db.transaction(function (tx) { for (var i=0; i<=numberofArticles-1; i++){ tx.executeSql('INSERT INTO LOGS (articleID) VALUES (?)', [i]); }; }); </script>
And an alternative, the correct closed-loop path, which in this case is not needed
for (var i=0; i<=numberofArticles-1; i++){ (function(i) { db.transaction(function (tx) { tx.executeSql('INSERT INTO LOGS (articleID) VALUES (?)', [i]); }); })(i); };
RichardTheKiwi
source share