I've got a nice little shopping basket where if the user deletes an item, the slideup jquery function is called and is disappears. In the back ground, I'm removing it from the db with a call to a code igniter controller.
function delete_booking(id_booking, amount) {
if (user_total == null || user_total == '') {
var user_total = parseFloat(0);
}
$.ajax({
type: "POST",
data: '',
url: "/"+id_booking,
});
$("#booking_id_"+id_booking).slideUp();
var user_total = (parseFloat() - parseFloat() - parseFloat(user_total));
alert(user_total);
alert(parseFloat(user_total));
$('#booking_total').html(user_total);
}
What I can't fathom, is when I update the user total: $('#booking_total') I need somehow to have the function remember the NEW total... I've googled 'remembering JavaScript var' and similar, but I can't find exactly what I need... My only other option is to do another call to the db with ajax to get the new total, but there MUST be a JS way to do this?