I really have nothing to do at the company today, so I suddenly thought of writing down the front-end framework of the shopping cart in the mall. Of course, I only have the addition, deletion, modification, and query of the shopping cart here. Maybe the writing is not that perfect, but the most important thing is an introduction. I hope JS experts can give me some suggestions so that I can reach a higher level. HOHO~~~ Let’s start: Js:
" ; document.body.innerHTML =html; } function AddToPanel(data) { //This is to add an item to the shopping cart to modify the frontend style var obj = document .getElementById("sm"); var html = "
" "" "
" "
" data.Name "
" "
" "¥" data.Money "
" "
" "
" "" " "title="Quantity minus one" class="cut" onclick="Jusoc.UI.ShoppingCart. Minus(1,this.parentNode.childNodes[0].value,this.parentNode.childNodes[0])">" "
" " td>" "
" "Remove From Cark< /span>" "
"; var row = obj.insertRow(1); row.innerHTML = html; return; obj.childNodes[0 ].innerHTML = html; } function UpdatePanel(obj, count) { //Here are the modification operations to add or subtract from the shopping cart obj.value = count; } function RemoveFromPanel(child) { var obj = document.getElementById("sm"); obj.childNodes[0].removeChild(child); } return { PageLoad: function () { Constract(); }, Add: function (pid, pcount) { Jusoc.BLL.Shopping.Add(pid,pcount, null , AddToPanel); }, Plus: function (pid, pcount, obj) { pcount = parseInt(pcount) 1; Jusoc.BLL.Shopping.Set(pid, pcount, function () { alert("before") }, function (data) { UpdatePanel(obj, pcount) }); }, Minus:function(pid,pcount,obj){ pcount = parseInt (pcount) - 1; Jusoc.BLL.Shopping.Set(pid,pcount,null,function(data){ UpdatePanel(obj,pcount)}); }, Remove:function(pid ,obj){ Jusoc.BLL.Shopping.Remove(pid,null,function(data){ RemoveFromPanel(obj);}); } } })() } Jusoc._inital(); })()
Tips: The display page here is just a demo. If necessary, you can customize it yourself. HTML:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn