lundi 20 avril 2015

Input Total Product Price with GST Function

I would like the sub total value to be toFixed(2), so that the sub-total input will display "864.91" instead of "864.9100000000001".

Also, I have 2 inputs below sub-total called GST and total_price.

Basically, GST should take the sub-total value and multiply it by (5/100) and display it in the GST input value.

The total price should take the GST value and the sub-total value, add them together, and display the number in the total_price input value.

  1. Any ideas on what code I can use to do this?
  2. I would also like all values to be no longer than 2 decimal places like the sub-total input value (864.91 instead of 864.9100000...).

Here is the code I have so far:

function selectProduct(sel) {
    var end = sel.value;
    var typeId = sel.id;
        $.ajax({    //create an ajax request to load_page.php
            type: "GET",
            url: "ajax_all.php?from=pos_product&name="+end,
            dataType: "html",   //expect html to be returned
            success: function(response){
                var sub_total = $("#sub-total").val();
                $("#sub-total").val(+sub_total + +response);

            }
    });
}

Thank you for any help, all help is greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire