日期:2013-05-14  浏览次数:21167 次

cart.js


请存为cart.js,并且和前部分html放在同一个目录中

//------------------------------------------------------------------------------
//
// file name :       cart.js
//
// description:      购物车前台用javascript 函数库
//
// function list :   On_Cancel(txtAmount , txtSum)---- 取消该项
//                   On_Update()                  ---- 更新数量
//                   On_Del()                     ---- 全部删除
//                   UpdateDate()                 ---- 更新表单显示
//                   Round()                      ---- 四舍五入取指定小数位数
//
// Aurthor:          LiuYunpeng
//
// Date:             2000/09/03
//
// History:          2000/09/03 version 1.0
//
//------------------------------------------------------------------------------


//----------------code begin here------------------------------------------

  function On_Cancel(txtAmount , txtSum)
    {
      txtAmount.value = 0 ;
      txtSum.value = 0 ;
      UpdateData();      
    }

  //更新表单显示
  function UpdateData()
    {
      var m_aAmount   = new Array() ;
      var m_aPrice    = new Array() ;
      var m_aDiscount = new Array() ;
      var m_aSum      = new Array() ;
      var m_numTotal  = 0 ;
      var i , j , k  , m;
      i = 0 ;
      j = 0 ;
      k = 0 ;
      m = 0 ;
      
      //求数量
      for (i = 0 ; i < document.frmOrder .elements .length ; i ++ )
        {
           if (frmOrder.elements [i].name.substring(0 , 9) == "txtAmount")
             {
               m_aAmount[j] = frmOrder.elements [i].value ;
               j ++ ;
             }
           if (frmOrder.elements [i].name.substring(0 , 14) == "txtTicketPrice")