var ids =[];

$(document).ready(function() {

    $(':input:checked').each(function () {
        ids += $(this).attr('rel');
    })

    $('.btn-lista-compra').on('click', function (e) {
        get_checkeds();

        window.location.href = 'http://www.delsuper.es/inutralia?ids='+ids.toString()
    })

    $('.btn-delete-checked').on('click', function (e) {
        get_checkeds();

        $.ajax({
            url: "listacompra/delete",
            type: "POST",
            method:"post",
            data: {
                id: $('#profile_id').val(),
                inputs: inputs

            },
            success: function (data) {

                if(data != "" && data != 0){
                    // Modal success
                    $('#modalSuccess').modal('show');
                }else{
                    // Modal error
                }

                setTimeout(function(){
                    location.reload();
                }, 2000);

            }
        })

    })

});



function get_checkeds()
{
    $(':input:checked').each(function () {
        let id_val = $(this).attr('rel');
        if( jQuery.inArray(id_val, ids)<0)
        {
            ids.push(id_val);
        }
    });
}