I am building an HTML line in jQuery to append to a table in the HTML and want to capture when the input value changes. I am trying to pass a variable obj.attNewChum
in the onchange
attibute as follows:
contents = contents + "<input type='text' id='" + obj.cdId + "' name='" + obj.cdId + "' value='" + attMeeting + "' onchange='attendanceUpdateFunction(this.id, this.value, "+obj.attNewChum+")'>";
However, this gives the following error in the console:
Uncaught ReferenceError: N is not defined
at HTMLInputElement.onchange (Attendance.html:1)
attendanceUpdateFunction(this.id, this.value, N)
The variable obj.attNewChum
does contain the value N
.
I have tried putting the variable in quotes:
contents = contents + "<input type='text' id='" + obj.cdId + "' name='" + obj.cdId + "' value='" + attMeeting + "' onchange='attendanceUpdateFunction(this.id, this.value, "+"\"'obj.attNewChum'\""+")'>";
And that gives the following error in the console:
Uncaught SyntaxError: Invalid or unexpected token