I've created some checkboxes dynamically using JavaScript (below), any ideas on how to call a function when a checkbox is clicked (has its state changed)?
var eng_types = table[3].slice(3);
for(var i in eng_types) {
    var name = eng_types[i];
    // Create the necessary elements
    var label = document.createElement("label");
    var checkbox = document.createElement("input");
    var description = document.createTextNode(name);
    checkbox.type = "checkbox";     // Make the element a checkbox
    checkbox.value = name;          // Make its value "pair"
    checkbox.name = i;              // Give it a name we can check
    label.appendChild(checkbox);    // Add the box to the element
    label.appendChild(description); // Add the description to the element
    // Add the label element to your div
    document.getElementById('eng_options').appendChild(label);
}
Any ideas on how to make each checkbox appear on a new line would also be appreciated.
Thanks in advance!
 
     
     
    