I am trying to store JavaScript function in the database. Every row in the database will have a different function. Depending on the row called a specific function will execute in the browser.
Some clarification: I am not trying to execute the function at the server. It will only be stored at the server and fetched to the client and would be executed like any other javascript function.
First, my question is, is this possible. I have been reading that javascript allows functions to be stored in variables, so I thought why not in the database. This will give me the freedom to execute a different function based on the row.
Second, I have been getting this error:
>a=cell._cell.row.data.jsfunction
"function toCelsius(fahrenheit) {
return (5/9) * (fahrenheit-32);
}"
>a()
VM435:1 Uncaught TypeError: a is not a function
at eval (eval at cellClick (empRead.html:14), <anonymous>:1:1)
at t.cellClick (empRead.html:21)
at w.edit (tabulator.min.js:6)
at HTMLDivElement.<anonymous> (tabulator.min.js:6)
It is a simple Fahrenheit to Celsius conversion function. I am afraid it is treating a variable as a string. But then how to tell it, I want it to be treated as a function. Is there any workaround to achieve it.
thanks