⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatecart.asp

📁 Windows Web脚本开发指南/(美) Dan Heflin, Todd Ney著 的源码
💻 ASP
字号:
<%@ LANGUAGE=JavaScript %>
<!-- #include file=commonSource.inc -->
<html>
<head>
<title>Product Catalog</title>
<base target="_self">
</head>
<body>
<%
  var menuTransform = Application("menuTransform");
  var catalogMenu = Application("catalogMenu");
  var subCatalog = Session("subcatalogList");
  var cart = Session("cart");
  buildNavigate();
  updateCart(Request.QueryString("catID"));

function updateCart(catID){
  // Called by the click of the update cart button in the cart page. Loops through the text
  // elements and updates the quantity based on the new value. If there isn't a value or
  // the quantity is 0  the item is removed from the cart

  var temp = new String(Request.Form);
  
  //Divide up the form string by each element
  var formElements = temp.split("&");
  var values;
  var itemID;
  var quantityElement;
  var item;
  
  for (var count=0; count<formElements.length; count++){
    //Split element string into the element name and value 
    values = formElements[count].split("=");
    itemID = values[0];
    controlValue = values[1];
    if (controlValue == "" || controlValue == 0 ){
      item = cart.selectSingleNode("//item[@id='" + itemID + "']");
      cart.documentElement.removeChild(item);
    }
    else {
      if(isNaN(controlValue)){
        Response.Write("<FONT size=4><STRONG>The quantity must be numeric.<BR>");
        Response.Write("Click on your browser's back button to return to the previous page.</STRONG></FONT>"); 
        return;
      }
      else{
        quantityElement = cart.selectSingleNode("//item[@id='" + itemID + "']/quantity");
        quantityElement.text = controlValue;
      }   
    }
  }
  Session("cart") = cart  ;
  displayHeader(catID);
  displayCart(catID);
}
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -