Front desk manager for shopping cart-only once with Server (ii)

Source: Internet
Author: User
Program | server | Shopping Cart | interactive cart.js

Please save it as cart.js and put it in the same directory as the previous part of the HTML

//------------------------------------------------------------------------------
//
File Name:cart.js
//
Description: JavaScript function library for shopping cart foreground
//
function List:on_cancel (Txtamount, txtsum)----Cancel the item
On_update ()----Update quantity
On_del ()----Delete all
Updatedate ()----Update form display
Round ()----rounded to the specified number of decimal places
//
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 ();
}

Update form Display
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;

Ask for quantity
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) = = "Txtticketprice")
{

M_aprice[k] = Round (Frmorder.elements[i].value, 2);
K + +;
}
if (frmorder.elements [i].name.substring (0) = = "Hidticketdisco")
{
M_ADISCOUNT[M] = Frmorder.elements[i].value;
m + +;
}
}

for (i = 0; i < K; i + +)
{
M_asum[i] = Round (m_aprice[i] * m_aamount[i] * m_adiscount[i]/100, 2);

}


Update Form
j = 0;
for (i = 0; i < Document.frmorder. elements. length; i + +)
{
if (frmorder.elements [i].name.substring (0, 6) = = "Txtsum")
{
frmorder.elements [i].value = M_asum[j];
M_numtotal = Round (M_numtotal + m_asum[j], 2);
j + +;
}

}

Document.frmorder. txttotal. value = M_numtotal;

return 0;
}

Number of updates
function On_update ()
{

if (Document.frmorder. btnupdate. Value = = "Modified quantity")
{
Document.frmorder. btnupdate. Value = "Number of updates"
for (Var i=0 i < frmOrder.elements.length; i++)
{
if (frmorder.elements [i].name.substring (0, 9) = = "Txtamount")
{

frmorder.elements [i].disabled = false;
Frmorder.elements[i].style.borderstyle = "Ridge";
Document.frmorder. btnbuy. Disabled = true;
Document.frmorder. btncancel. Disabled = true;
Document.frmorder. btncontinue. Disabled = true;
Document.frmorder. Btndel. Disabled =true;
}

}
}
Else
{
Alert (Document.frmorder. btnupdate. Value);
Document.frmorder. btnupdate. Value = "Modified Quantity"
var j = 0;
var m_aprice = new Array ();
var m_aamount = new Array ();
for (Var i=0 i < frmOrder.elements.length; i++)
{
if (frmorder.elements [i].name.substring (0, 9) = = "Txtamount")
{

frmorder.elements [i].disabled = true;
Frmorder.elements[i]



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.