I need to associate a dynamic javascript function with checkbox along with other data in an array. For example. I have the following javascript array:
var arr = ['hello', 'world'];
arr.unshift('buddy');
var index = 1;
arr.unshift('<input type="checkbox" id = "' + index + '" onchange="boxChange(" + index + ")>');
The first element in the above array is a checkbox that has an onchange event. The event triggers the function boxChange that has the index passed in.
but the above checkbox event doesn't work, I guess the syntax (quotes) is not right. I need some help with correcting the "quotes". Thanks
I have an imcomplete code written in jsFiddle here http://jsfiddle.net/qq0dsz0f/