Stop form and add parameters by jQuery

Hi.

I need help, to edit the forms.

I need that by clicking on the save button, I can execute the jQuery, add parameters and send the request.

Does anyone know how to do it correctly? @Kovah

Thank you.

It is not for bills. It is for everything. Products, Customers, Payments, etc. I want to give the button to save, power to execute with jQuery, add parameters and return with the execution of the form with the new parameters.

I have tried with e.preventDefault (), the execution stops, I do my functions and calculations, but when I want to continue with the execution of the submit, it does not take my modified data, if not the data of the original form.

This does not work.

$('#form_product').submit(function(e) {
        e.preventDefault();
        
        var form = $(this);
        var formData = $(form).serializeArray();
        
        var proveedores = [];
        $('#proveedores .proveedor').each(function(){
            var prov = {
                'supplier_id' : $(this).attr('supplier_id'),
                'purchase_price_suplier' : $(this).find('.purchase_price_suplier').html()
            };
            
            proveedores.push(prov);
        });
        formData.push({'proveedores':proveedores});
        
        $.ajax({
            type: 'POST',
            url: $(form).attr('action'),
            dataType: "json",
            data: formData
        });
    });

Can’t help you with this specific request at the moment but sounds more like a general javascript question, not directly related to Invoiceplane. I suggest heading over to Stackoverflow.

Right @Kovah , it’s not an InvoicePlane problem. It is a query about programming. I need to submit a form, add data with jQuery and follow the execution of the submit. It is in case someone knows how to do it, since my code does not work well. Just take the form data.