I am using DataTables and have a checkbox. On change I trigger a function. I want to pass two variables to the function like so:
{data: null,
className: "center",
render: function(data,type,row) {
alert(data.sesId);
if(data.checkedIn === "N"){
return ("<input type='checkbox' id=" + data.patId + " name='update' onchange='patientCheckInFunction(this," + data.sesId + ")' style='zoom: 2.0;'>");
}else{
return ("<input type='checkbox' id=" + data.patId + " name='update' onchange='patientCheckInFunction(this," + data.sesId + ")' style='zoom: 2.0;' checked>");
}
},
},
This gives me an "Unexpected token ')'" in the console log.
There is no error if I have:
return ("<input type='checkbox' id=" + data.patId + " name='update' onchange='patientCheckInFunction(this)' style='zoom: 2.0;'>");
However, I do want to pass both variables.
Try like this:
return ("<input type='checkbox' id='"+ data.patId +"' name='update' onchange='patientCheckInFunction(\"" + this + "\",\"" + data.sesId +"\")' style='zoom: 2.0;'>");
I was not using "name" so I ended up doing this:
return ("<input type='checkbox' id=" + data.patId + " name=" + data.sesId + " onchange='patientCheckInFunction(this, this.name)' style='zoom: 2.0;'>");