I am trying to create JSON object entered into textbox using below code.
colnames is array of columns from table colnames = [DEPTNO,DNAME],
I am trying to create JSON object dynamically. eg
tableInsert.DEPTNO = 100; tableInsert.DNAME= sales;
but when i run it, it always complain console.log (eval ("tableInsert." + col)); is undefined. Any help..
document.getElementById("insercols").onclick = function(){
var tableInsert ='';
var colvalue='';
console.log("cols are " + colnames);
for (col of colnames){
colvalue = document.getElementById(col).value;
eval ("tableInsert." + col + " = " + "typeof "+ colvalue);
console.log("tableInsert." + col + " = " + "typeof "+ colvalue);
console.log (eval ("tableInsert." + col));
}
}
define tableinsert as and try again..
var tableInsert = {};
tableInsert[col] = typeof colvalue;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.