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

📄 cart1.asp

📁 体育商城
💻 ASP
📖 第 1 页 / 共 2 页
字号:
      }
      iDest++;
		}
	}
  this.SC = tmpSC;
  this.persist();
}

function UCGetColNamesSerial(colDelim) {
  var serialCols = "";
  for (var iCol=0; iCol<this.numCols; iCol++) {
    if (iCol != 0) serialCols += colDelim;
    serialCols += this.colNames[iCol];
  }
  return serialCols;
}

function UCGetContentsSerial(colDelim, rowDelim) {
  var serialCart = "";
  for (var iRow=0; iRow<this.GetItemCount(); iRow++) {
    if (iRow != 0) serialCart += rowDelim
    for (var iCol=0; iCol<this.numCols; iCol++) {
      if (iCol != 0) serialCart += colDelim;
      serialCart += this.SC[iCol][iRow];
    }
  }
  return serialCart;
}

function UCSetContentsSerial(serialCart, colDelim, rowDelim) {
	var Rows = String(serialCart).split(rowDelim)
	for (iRow = 0; iRow < Rows.length; iRow++) {
		if (Rows[iRow] != "undefined" && Rows[iRow] != "") {
			Cols = Rows[iRow].split(colDelim)
			iCol = 0
			for (iCol = 0; iCol<Cols.length; iCol++) {
				this.SC[iCol][iRow] = Cols[iCol]
			}
		}
	}
	this.persist();
}

function SetCookie(){
	var cookieName = this.GetCookieName()
	var cookieStr = this.GetContentsSerial(this.cookieColDel, this.cookieRowDel)
	var cookieExp = GetCookieExp(this.cookieLifetime)
	Response.Cookies(cookieName) = cookieStr
	Response.Cookies(cookieName).expires = cookieExp
}

function GetCookieName(){
	var server = Request.ServerVariables("SERVER_NAME");
	return  server + this.Name;
}

function UCDestroyCookie(){
	cookieName = this.GetCookieName();
	Response.Cookies(cookieName) = ""
	Response.Cookies(cookieName).expires = "1/1/90"
}

function PopulateFromCookie(cookieStr){
  this.SetContentsSerial(cookieStr, this.cookieColDel, this.cookieRowDel)
}

// ***************** debug code ********************
function assert(bool, msg) {
	if (!bool) {
		Response.Write("<BR><BR>An error occured in the UltraDev shopping cart:<BR>" + msg + "<BR>");
		//Response.End();
	}
}

function AssertCartValid(colNames, msg) {
	// go through all cart data structures and insure consistency.
	// For example all column arrays should be the same length.
	// this function should be called often, especially just after
	// makeing changes to the data structures (adding, deleting, etc.)
	// also verify we always have the required columns:
	// ProductID, Quantity, Price, Total

	// the input arg is some I add as I code this package like
	// "Prior to return from AddToCart"
	//
	var ERR_COOKIE_SETTINGS = "Cookie settings on this page are inconsistent with those stored in the session cart<BR>"; 
	var ERR_BAD_NAME = "Cart name defined on this page is inconsistent with the cart name stored in the session<BR>";
	var ERR_COLUMN_COUNT = "The number of cart columns defined on this page is inconsistent with the cart stored in the session<BR>";
	var ERR_REQUIRED_COLUMNS = "Too few columns; minimum number of columns is 4<BR>";
	var ERR_REQUIRED_COLUMN_NAME = "Required Column is missing or at the wrong offset: ";
	var ERR_COLUMN_NAMES = "Cart column names defined on this page are inconsistent with the cart stored in the session";
	var ERR_INCONSISTENT_ARRAY_LENGTH = "Length of the arrays passed to cart constructor are inconsistent<BR>"
	var errMsg = "";
	var sessCart = Session(this.Name);

	if (sessCart != null) { // Validate inputs against session cart if it exists
		if (sessCart.Name != this.Name) errMsg += ERR_BAD_NAME;
		if (this.numCols < 4) errMsg += ERR_REQUIRED_COLUMNS;
		if (sessCart.numCols != this.numCols) errMsg += "Column Name Array: " + ERR_COLUMN_COUNT;
		if (sessCart.numCols != this.colComputed.length) errMsg += "Computed Column Array: " + ERR_COLUMN_COUNT;
		if (sessCart.bStoreCookie != this.bStoreCookie) errMsg += "Using Cookies: " + ERR_COOKIE_SETTINGS;
		if (sessCart.cookieLifetime != this.cookieLifetime) errMsg += "Cookie Lifetime: " + ERR_COOKIE_SETTINGS;

		// check that required columns are in the same place
		var productIndex = this.GetIndexOfColName(this.PRODUCTID);
		var quantityIndex = this.GetIndexOfColName(this.QUANTITY);
		var priceIndex = this.GetIndexOfColName(this.PRICE);
		var totalIndex = this.GetIndexOfColName(this.TOTAL);

		if (colNames[productIndex] != "ProductID") errMsg += ERR_REQUIRED_COLUMN_NAME + "ProductID<BR>";
		if (colNames[quantityIndex] != "Quantity") errMsg += ERR_REQUIRED_COLUMN_NAME + "Quantity<BR>";
		if (colNames[priceIndex] != "Price") errMsg += ERR_REQUIRED_COLUMN_NAME + "Price<BR>";
		if (colNames[totalIndex] != "Total") errMsg += ERR_REQUIRED_COLUMN_NAME + "Total<BR>";
	}
	else { // if cart doesn't exist in session, validate input array lengths and presence of reqiured columns
		if (this.numCols != this.colComputed.length) errMsg += ERR_INCONSISTENT_ARRAY_LENGTH;
		
		var bProductID = false, bQuantity = false, bPrice = false, bTotal = false;

		for (var j = 0; j < colNames.length; j++) {
			if (colNames[j] == "ProductID") bProductID = true;
			if (colNames[j] == "Quantity") bQuantity= true;
			if (colNames[j] == "Price") bPrice = true;
			if (colNames[j] == "Total") bTotal = true;
		}
		if (!bProductID) errMsg += ERR_REQUIRED_COLUMN_NAME + "ProductID<BR>";
		if (!bQuantity) errMsg += ERR_REQUIRED_COLUMN_NAME + "Quantity<BR>";
		if (!bPrice) errMsg += ERR_REQUIRED_COLUMN_NAME + "Price<BR>";
		if (!bTotal) errMsg += ERR_REQUIRED_COLUMN_NAME + "Total<BR>";
	}
	
	if (errMsg != "") {
		Response.Write(msg + "<BR>");
		Response.Write(errMsg + "<BR>");
		Response.End();
	}
}

function VBConstuctCart(Name, cookieLifetime, vbArrColNames, vbArrColComputed){
	var myObj;
	var a = new VBArray(vbArrColNames);
	var b = new VBArray(vbArrColComputed);
	eval("myObj = new UC_ShoppingCart(Name, cookieLifetime, a.toArray(), b.toArray())");
	return myObj;
}
</SCRIPT>
<SCRIPT LANGUAGE=vbscript runat=server NAME="UC_CART">
Function GetCookieExp(expDays) 
 	vDate = DateAdd("d", CInt(expDays), Now())
 	GetCookieExp = CStr(vDate)
End Function
</SCRIPT>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT NAME="UC_CART">
function DoNumber(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
	DoNumber = FormatNumber(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
End Function

function DoCurrency(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
	DoCurrency = FormatCurrency(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
End Function

function DoDateTime(str, nNamedFormat, nLCID)
	dim strRet
	dim nOldLCID

	strRet = str
	If (nLCID > -1) Then
		oldLCID = Session.LCID
	End If

	On Error Resume Next

	If (nLCID > -1) Then
		Session.LCID = nLCID
	End If

	If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
		strRet = FormatDateTime(str, nNamedFormat)
	End If
										
	If (nLCID > -1) Then
		Session.LCID = oldLCID
	End If			
										
	DoDateTime = strRet
End Function

function DoPercent(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
	DoPercent = FormatPercent(str, nDigitsAfterDecimal, nLeadingDigit, nUseParensForNeg, nGroupDigits)
End Function							

function DoTrim(str, side)
	dim strRet
	strRet = str

	If (side = "left") Then
		strRet = LTrim(str)
	ElseIf (side = "right") Then
		strRet = RTrim(str)
	Else
		strRet = Trim(str)
	End If
	DoTrim = strRet
End Function
</SCRIPT>
<%
UC_CartColNames=Array("ProductID","Quantity","productName","Price","totalweight","weight","Total")
UC_ComputedCols=Array("","","","","weight","","Price")
set UCCart1=VBConstuctCart("UCCart",2,UC_CartColNames,UC_ComputedCols)
UCCart1__i=0
%>
<%
Dim Repeat2__numRows
Repeat2__numRows = 10
Dim Repeat2__index
Repeat2__index = 0
tuijian_numRows = tuijian_numRows + Repeat2__numRows
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = 10
Dim Repeat1__index
Repeat1__index = 0
hot_numRows = hot_numRows + Repeat1__numRows
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
  NextItem = "&" & Item & "="
  If (InStr(1,MM_removeList,NextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
  End If
Next

' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
  NextItem = "&" & Item & "="
  If (InStr(1,MM_removeList,NextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
  End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> "")  Then MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
  If (firstItem <> "") Then
    MM_joinChar = "&"
  Else
    MM_joinChar = ""
  End If
End Function
%>
<%
Dim Repeat3__numRows
Repeat3__numRows = 7
Dim Repeat3__index
Repeat3__index = 0
news_numRows = news_numRows + Repeat3__numRows
%>
<%
Dim HLooper3__numRows
HLooper3__numRows = 4
Dim HLooper3__index
HLooper3__index = 0
dazhe_numRows = dazhe_numRows + HLooper3__numRows
%>
<%
Dim HLooper2__numRows
HLooper2__numRows = 2
Dim HLooper2__index
HLooper2__index = 0
newproduct_numRows = newproduct_numRows + HLooper2__numRows
%>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>	
function DoTrimProperly(str, nNamedFormat, properly, pointed, points)
  dim strRet
  strRet = Server.HTMLEncode(str)
  strRet = replace(strRet, vbcrlf,"")
  strRet = replace(strRet, vbtab,"")
  If (LEN(strRet) > nNamedFormat) Then
    strRet = LEFT(strRet, nNamedFormat)			
    If (properly = 1) Then					
      Dim TempArray								
      TempArray = split(strRet, " ")	
      Dim n
      strRet = ""
      for n = 0 to Ubound(TempArray) - 1
        strRet = strRet & " " & TempArray(n)
      next
    End If
    If (pointed = 1) Then
      strRet = strRet & points
    End If
  End If
  DoTrimProperly = strRet
End Function
</SCRIPT>
<html>
<head>
<title>购物车</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="ddd.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="2" marginwidth="0" marginheight="0">
<table width="680" border="0" cellspacing="0" cellpadding="0" align="center" height="107" class="bk1">
  <tr> 
    <td valign="top" height="145"> 
      <form name="form1" method="get" action="">
        <table width="562" border="1" cellspacing="2" cellpadding="0" align="center" class="dfont" bordercolor="#000000">
          <tr bgcolor="#99CC00"> 
            <td width="138"> 
              <div align="center">商品名称</div>
            </td>
            <td width="155"> 
              <div align="center">商品编号</div>
            </td>
            <td width="93"> 
              <div align="center">单价</div>
            </td>
            <td width="67"> 
              <div align="center">数量</div>
            </td>
            <td width="85"> 
              <div align="center">合计</div>
            </td>
          </tr>
          <tr> 
            <td width="138" height="4"> 
              <div align="center"><a><%=(UCCart1.GetColumnValue("productName",UCCart1__i))%></A></div>
            </td>
            <td width="155" height="4"> 
              <div align="center"><%=(UCCart1.GetColumnValue("ProductID",UCCart1__i))%></div>
            </td>
            <td width="93" height="4"> 
              <div align="center"><%=(UCCart1.GetColumnValue("Price",UCCart1__i))%>元</div>
            </td>
            <td width="67" height="4"> 
              <div align="center"> 
                <input type="text" name="textfield" size="4" value="<%=(UCCart1.GetColumnValue("Quantity",UCCart1__i))%>">
                <input type="checkbox" name="ddd" value="0">
              </div>
            </td>
            <td width="85" height="4"> 
              <div align="center"><%=(UCCart1.GetColumnValue("Total",UCCart1__i))%>元</div>
            </td>
          </tr>
          <tr> 
            <td colspan="2" height="6">&nbsp; </td>
            <td width="93" bgcolor="#99CC00" height="6"> 
              <div align="center">合计费用:</div>
            </td>
            <td colspan="2" height="6"> 
              <div align="center"></div>
              <div align="center"><%=(UCCart1.GetColumnTotal("Total"))%>元</div>
            </td>
          </tr>
        </table>
        <div align="center"><br>
          <table width="448" border="0" cellspacing="0" cellpadding="0" align="center">
            <tr> 
              <td width="150"> 
                <div align="center"> 
                  <input type="image" border="0" name="imageField" src="images/upcart.gif" width="104" height="20">
                </div>
              </td>
              <td width="182"> 
                <div align="center"><img border=0 src="images/rushcart.gif" width="104" height="20"></div>
              </td>
              <td width="116"> 
                <div align="center"><a href="default.asp"><img src="images/jixugw.gif" width="104" height="20" border="0"></a></div>
              </td>
            </tr>
          </table>
          <input type="submit" name="Submit" value="Submit">
          <p><a href="order.asp"><img src="images/check.gif" width="134" height="32" border="0"></a></p>
        </div>
      </form>
    </td>
  </tr>
</table>

</body>
</html>


<html></html>

⌨️ 快捷键说明

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