日期:2011-11-27  浏览次数:20995 次

二、js函数:orderform_functions.js

//Vampirebat,2002-1-16;http://www.vampirebat.org

//<--Start--从cookie中读出订单数据的函数
function ReadOrderForm(name)
{
    var cookieString=document.cookie;
    if (cookieString=="")
    {
        return false;
    }
    else
    {
        var firstChar,lastChar;
        firstChar=cookieString.indexOf(name);
        if(firstChar!=-1)
        {
            firstChar+=name.length+1;
            lastChar = cookieString.indexOf(';', firstChar);
            if(lastChar == -1) lastChar=cookieString.length;
            return cookieString.substring(firstChar,lastChar);
        }
        else
        {
            return false;
        }
    }    
}
//-->End

//<--Start--添加商品至购物车的函数
function SetOrderForm(item_no,item_name,item_amount,item_price)
{
    var cookieString=document.cookie;
    if (cookieString.length>=4000)
    {
        alert("您的订单已满\n请结束此次订单操作后添加新订单!");
    }
    else if(isNaN(item_amount)||item_amount<1||item_amount.indexOf('.')!=-1)
    {
        alert("数量输入错误!");
    }
    else
    {
        var mer_list=ReadOrderForm('24_OrderForm');
        var Then = new Date();
        Then.setTime(Then.getTime()+30*60*1000);
        var item_detail="|"+item_no+"&"+item_name+"&"+item_amount+"&"+item_price;
        if(mer_list==false)
        {
            document.cookie="24_OrderForm="+escape(item_detail)+";expires=" + Then.toGMTString();
            alert("“"+item_name+"”\n"+"已经加入您的订单!");
        }
        else
        {
            if (mer_list.indexOf(item_no)!=-1)
            {
                alert('此商品您已添加\n请进入订单修改数量!')
            }
            else
            {
       &n