I am creating a ecommerce site for my final year project.while I am creating a project I ran in to the problem with product shall be able add the card but when I view the card product shown which I added into the card.my problem is if the give qty it will auto calculation and display result on the total textbox.and final totel show display below. I attached image below what i tried so far. But couldn’t calculate the total and final total.
**Display the Products**
[![enter image description here](https://i.stack.imgur.com/Nbcxk.jpg)](https://i.stack.imgur.com/Nbcxk.jpg)

```
<script>
getProducts();

    function getProducts() {
        $.ajax({
            type: 'GET',
            url: 'all_cart.php',
            dataType: 'JSON',
            success: function(data) {
                data.forEach(function(element) {
                    var id = element.id;
                    var product_name = element.product_name;
                    var price = element.price;
                   $('#mytable tbody').after
                   (
                        '<tr> ' +
                        '<td>' + id + '</td>' +
                        '<td>' + product_name + '</td>' +
                        '<td>' + price + '</td>' +
                        "<input type='hidden' name='price' value='" + price + "'>" +
                        '<td>' + "<input type = 'text' id='qty' name='qty'/>" + '</td>' +
                        '<td>' + "<input type = 'text' id='amount'/>" + '</td>' +
                        '</tr>');
                  });
            },
            error: function(xhr, status, error) {
                alert(xhr.responseText);
            }
        });
    }

```

**Auto calcaltion the price \* qty**

```
$(function() {
    $("#price, #qty").on("keydown keyup click", qty);
    function qty() {
        var sum = (
        Number($("#price").val()) * Number($("#qty").val())
        );

        $('#amount').val(sum);
        console.log(sum);
    }
});

```