Recently learning native JavaScript, need to get a shopping cart function, below is a demo using cookies
The idea is actually very simple, the commodity interface through value to get the corresponding value, and then put the various information of this commodity into a dictionary, because there are multiple products, the dictionary objects of these products are placed in an array inside the line. This array is then serialized through JSON and stored in a cookie. In the shopping cart interface, you get this information by reading a cookie, and then dynamically create a table to display it.
Product interface
<! Doctype html>
650) this.width=650; "src=" https://s4.51cto.com/wyfs02/M01/95/FA/wKiom1kbyLjCuA7ZAAEOo9zU3hw409.jpg "style=" float : none; "title=" 1.JPG "alt=" Wkiom1kbyljcua7zaaeoo9zu3hw409.jpg "/>
The Shopping Cart interface
<! Doctype html>650) this.width=650; "src=" https://s1.51cto.com/wyfs02/M02/95/FA/wKioL1kbyLnBsHN6AADbO8Cconc503.jpg "title=" 2.JPG "Style=" Float:none; "alt=" wkiol1kbylnbshn6aadbo8cconc503.jpg "/>
Content of Cookies
650) this.width=650; "src=" https://s1.51cto.com/wyfs02/M01/95/FA/wKiom1kbyaejN8B1AACyL4WOf0I389.jpg "title=" 3.JPG "alt=" Wkiom1kbyaejn8b1aacyl4wof0i389.jpg "/>
This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1926569
Simple examples of cookies and JS shopping carts