用变量生成数据库web sql database 及操作需要JSON.stringfy/parse来操作:
var newstr = 'checkbox0,input1,textarea2,option3,date4,flag'
var newdatastr = '0,1,2,3,4,5'
const a = 'CREATE TABLE IF NOT EXISTS ' + taname + ' (id integer primary key AutoIncrement,'+newstr+')'
const b = JSON.stringify(a);
const c = 'INSERT INTO ' + taname + ' (' +newstr+ ') VALUES (' +newdatastr+ ')'
const d = JSON.stringify(c);
db.transaction(function (tx) {
tx.executeSql(
JSON.parse(b)
)
})
db.transaction(function (tx) {
tx.executeSql(
JSON.parse(d)
)
})