$(document).ready(function () {
    $("body").on('input', '.qty, .rate', Calc);

    function Calc() {
        var qty = parseFloat($('.qty').val() || 0);
        var rate = parseFloat($('.rate').val() || 0);

        var amount = qty * rate;
        $(".amount").val(amount);
    }

    $("#hprint").hide();


    function loadParty() {
        var shopwk = $('.shopwk').val();
        var selectedparty = $('#selectedparty').val();

        $.ajax({
            url: 'get_party.php',
            type: 'POST',
            data: {
                shopwk: shopwk,
                selectedparty: selectedparty
            },

            success: function (response) {

                $('.party').html(response);

                $('.party').trigger('change');
            }
        });
    }

    // FIRST LOAD
    loadParty();

    // CHANGE SHOPWK
    $('.shopwk').change(function () {

        $('#selectedparty').val('');

        loadParty();
    });


});