我以某种方式设法插入文本字段的内容使用文本字段id与下面的代码,但宁愿将文本字段中的任何内容分配给变量,然后插入该变量的值。如何在SQLite中将变量值插入到我的数据库中?
var newName = document.getElementById("txNewName").value;
var ing1 = document.getElementById("txIngredient1").value;
var ing2 = document.getElementById("txIngredient2").value;
var ing3 = document.getElementById("txIngredient3").value;
db.transaction(function(transaction) {
transaction.executeSql('INSERT INTO MyRecipes(MyRecipeName, MyIngredient1, MyIngredient2, MyIngredient3) VALUES (?,?,?,?)',[$('#txNewName').val(), $('#txIngredient1').val(), $('#txIngredient2').val(), $('#txIngredient3').val()]);
});
我正在使用SQLite,如果这有所作为,我是非常新的,所以将不胜感激任何帮助。
作为另一一边,你是混合的JavaScript和jQuery - 更好地坚持jQuery的语法,如果你正在使用它。 – Turophile