
function updateCount(id) {
    var listid = id;
    var num = /^[1-9]+[0-9]*]*$/;
    var ele = document.getElementById("item" + id);
    if (!num.test(ele.value)) {//不是数字
        alert("\u8bf7\u8f93\u5165\u6b63\u786e\u5546\u54c1\u4e2a\u6570");
        ele.focus();
        return;
    }
    var num = document.getElementById("unit" + listid).innerHTML;
    var added = parseInt(ele.value) - parseInt(document.getElementById("unit" + listid).innerHTML);
    var total = parseInt(ele.value) * parseFloat(document.getElementById("price" + listid).innerHTML);
    //var cartprice = document.getElementById("cartprice").innerHTML;
    //var cartprice = parseFloat(cartprice) + parseInt(added) * parseFloat(document.getElementById("price" + listid).innerHTML);
    document.getElementById("unit" + listid).innerHTML = ele.value;
    document.getElementById("total" + listid).innerHTML = total.toFixed(2);
    //document.getElementById("cartprice").innerHTML = cartprice.toFixed(2);
    var myAjax;
    var param = "action=updateCount&listid=" + listid + "&quantity=" + ele.value + "&random=" + getRandom(10);
    singleRequest(page_root+"/cashier/cart.do?" + param);
    //myAjax = new Ajax.Request("/cashier/cart.do", options);
}

function setIsCOD(listid, iscod) {
    var myAjax;
    var param = "action=setIsCOD&listid=" + listid + "&iscod=" + iscod + "&random=" + getRandom(10);
    singleRequest(page_root+"/cashier/cart.do?" + param);
}
function getRandom(bytes) {
    var str = "qwertyuiopasdfghjklmnbvcxz1234567890";
    var s = str.split("");
    var t = "";
    for (var i = 0; i < bytes; i++) {
        t += s[getRandomNum(1, 36)];
    }
    return t;
}//
function getRandomNum(lbound, ubound) {
    return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}