Hello,
I’m adding a total amount value to a DIV through a jQuery Ajax call everytime I add a new item to a shopping cart. I need this value to be a part of a difference calculation (payment-totalAmount
), but I’m having troubles getting the totalAmount
value.
I set the total amount in the function called SetTotalAmount
and then I try to get the value from the DIV tag in the submitPayment
actionevent:
<script type="text/javascript">
$(document).ready(function(){
$("#submitPayment").click(function(){
var paymentAmount = $("#paymentAmount").val();
var totalAmount = $("#totalTillAmount").val();
var difference = (paymentAmount-totalAmount);
$("#paymentTillAmount").html("betalt: "+paymentAmount);
//$("#totalTillAmount").html("total: "+totalAmount);
$("#difference").html("Tilbage: "+difference);
$("#paymentInfo").show('slow');
});
});
function SetTotalAmount()
{
$.post("Controller/TillController.php?action=3",
function(data)
{
$("#totalAmount").html(data);
$("#totalTillAmount").html(data);
}
);
}
</script>