I am trying to add a button from a javascript function (with the innerHTML method) that has another function as the onClick function. This onClick function has to take multiple parameters:
area.innerHTML += "<input type='image' src='images/del.jpg' width='15' height='15' " +
"onClick='del(" + info['_id'] + "," + key + "," + value + ")' />";
This is (I think) the most logical way to do this, but when I try to click the button there is no functioncall. This works with one single argument, so the problem has to be in the combination of the parameters with the “,”.
Does anybody know how to solve this?
update
The del function is a temporary testfunction
function del(id, key, value) {
console.log(id + key + value);
}
I think you just need your variabled to be passed as strings. Edit the onclick even to this: