Shopping cart in jquery with php and session

Qbone

New Member
Good day!I'm now learning this jquery by creating a basic shopping cart were as add to cart buttons, remove items and clear buttons works in jquery.The function is to save the added items on session and can remove and clear also by jquery. I have an idea now on how the jquery works on adding the items. But not on removing a single item or to clear all of them on the cart.Any help, suggestion are much appreciated.thanks... :DHere is the code I have done so far on shopping cart. This is in two files the index.php and cart.php were the add to cart button already working except for remove and clear. Because I was not able to run the session yet.Here it is:// for ajax $(document).ready(function(){ $(".add").click(function(){ var id = $(this).attr("proid"); var item = $("#item"+id).val(); var brand = $("#brand"+id).val(); var price = $("#price"+id).val(); var quantity = $("#quantity"+id).val(); $.ajax({ type: "POST", url: "cart.php", data: "id="+ id + "& item="+ item + "& brand="+ brand +"& price="+ price +"& quantity="+ quantity, success: function(data){ $("#jcart").html(data); } }); //ajax return false; }); //click function //show empty table $("#jcart").load("jcart.php"); //--> for options $(".remove").click(function(){ var id = $(this).attr("proid"); $.ajax({ type: "POST", url: "clear.php", data: "id="+ id, success: function(data){ $('#jcart').html(data) } }); }); $(".clear").click(function(){ $.ajax({ type: "POST", url: "clear.php", success: function(data){ $("#jcart").html(data) } }); }); });//for id clickI'm making difficult with the session on how the items being save then retrieve. Any ideas or help will much appreciated...thanks in advance!
 
Back
Top