I’m trying to write a query that extracts and transforms data from a table and then inserts into another table. It is working if I add string but when I add variable it doesn’t. It gave me empty table!
function dodb() {
var name = document.getElementsByName('prezime');
var elements = document.getElementsByName('bt');
for (var i = 0; i <= elements.length; i++) {
var oelements = elements[i];
oelements.onclick = (function(){
var name1 = name[i].firstChild.nodeValue;
return function() {
db.transaction(function (tx) {
var a = "INSERT INTO racersA SELECT * FROM racers WHERE prezime=%name1%";
tx.executeSql(a);
});
}
})(i);
}
}
You didn’t put any variables into your SQL, so since its simple Javascript you need to concatenate your variable with your string
Should be