[Answer]-How to check the checkbox field checked and fetch the attribute id value from the element in jquery and django

1👍

Try

jQuery(function ($) {
    $("#process_button").click(function () {
        //create an array of checked checkbox ids
        var ids = $('.css-checkbox_latest:checked').map(function (index) {
            return this.id;
        }).get();

        //if nothing is selected alert the user and stop further processing
        if (!ids.length) {
            alert('nothing is selected')
            return;
        }

        //send a request to server using an ajax POST request, it will contains an array of parameters called ids
        $.ajax({
            url: '<url>',
            type: 'POST',
            data: {
                ids: ids
            }
        })
    });
});

Leave a comment