[Django]-JavaScript function calls within Django form fields

3👍

You can dynamically add event handlers using JavaScript. You can add a script that, once the page is loaded, will find all checkboxes you want and add the handlers there. In jQuery, you can write something like this:

$(document).ready(function() {
    $(".my_form input[type=checkbox]").change(function() {
          //Some code here
    });
});

Be careful, I have not tested the code above! But should be enough to get you started.

Leave a comment