I am trying to get my function to work by adding another part to it i want to add a field that has a budget and diff_total so when i type my qty in the total will display and subtract from my budget
The 2 database fields that i am adding are:
budget and diff_total
diff_total = Budget - grand_total
The php used to add for this function originally is
The 2 database fields that i am adding are:
budget and diff_total
diff_total = Budget - grand_total
Code:
<SCRIPT> function calc_subtotal(param) { var total=$("#price"+param).attr('value')*$("#quantity"+param).attr('value'); $("#total"+param).text(total.toFixed(2)+''); update_grandtotal(); } function update_grandtotal() { var total=0; var arr=$("div[@id^='total']"); for (var i=0;i<arr.length;++i) total+=parseFloat(arr[i].textContent); $("#grandtotal").text(total.toFixed(2)+''); } function savedata() { var arr=$("input[@id^='id']"); for (var i=0;i<arr.length;++i) { var param=arr[i].value; var id=parseInt(param); var price = parseFloat($("#price"+param).attr('value')); var quantity = parseInt($("#quantity"+param).attr('value')); var total = parseFloat($("#total"+param).text()); $.post("save.php", { id: id, quantity: quantity, price: price, total: total } ); } } setTimeout("update_grandtotal();", 500); </SCRIPT>
The php used to add for this function originally is
PHP Code:
global $data;
$num = $data["item_uid"];
$value = "<div id=total" . $num . ">" . $value . "</div>";