/ Published in: jQuery
link to plugin http://projects.exvoto.org/jquery-extjsoncookie/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<html> <head> <script type="text/javascript" src="js/jquery-1.4.1.min.js"></script> <script type="text/javascript" src="js/jquery.json-2.2.js"></script> <script type="text/javascript" src="js/jquery.extjasoncookie-0.2.js"></script> <script> function onl(){ save2basket(1,1000,8); var getByid = getFromBasket(1); alert(getByid.price) // trace price alert(getByid.quantity) // trace q save2basket(1,1200,3); //change quantity or price } function getFromBasket(id){ var id = 'id'+String(id); return jQuery.extendedjsoncookie("getCookieVariable",id, "options"); } function save2basket(id,Price,Quantity){ var id = 'id'+String(id); var Price = String(Price); var Quantity = String(Quantity); jQuery.extendedjsoncookie("removeCookie",id); var opt = {price : Price,quantity : Quantity}; jQuery.extendedjsoncookie("setCookieVariable",id, "options", opt ); } function removeFromBasket(id){ var id = 'id'+String(id); jQuery.extendedjsoncookie("removeCookie",id); } </script> </head> <body onload='onl()'> </body> </html>