Live Update in stock Field based on Quantity Selected in the previous rows in table

Viewed 25

I am trying to update the stock based on quantity selected in the previous rows without any button click. In the image first row stock count (99) is from DB. I want the upcoming In Stock to change based on the quantity selected in the previous rows in the table.

Here is my work

Here is code :

This function is to update the In Stock based on the product selected in the dropdown (from database)

function available_quantity(id){
    $('.product_name').on('change', function (e) {
        var name = 'available_quantity_'+ id;
        var amount = 'product_rate_'+ id;
        console.log(amount);
        $.ajax({
            data: {"prodt": $('#prodt_'+id).val()}, 
            url: "assets/Get_Stock_Update.php",
            type: "post",
            success: function(data) {
                var splitted = data.split("/");
                console.log(splitted[0]+"|"+splitted[1]);
                $('.'+name).val(splitted[0]);
                $('#'+amount).val(splitted[1]);
            }
        });
    });
}
0 Answers
Related