日期:2014-05-16  浏览次数:20402 次

项目中用到的JS
function submitform(flag) {
            if (flag == 1) {
                jQuery("#productDTOListForm").attr("action", "buy.do?method=getProducts&type=good");
            }
            else if (flag == 2) {
                jQuery("#productDTOListForm").attr("action", "storage.do?method=getProducts&type=good");
            }
            else if (flag == 3) {
                var b = false;//是否有库存为0的商品
                jQuery("input[name='productIds']").each(function() {
                    if (jQuery(this).attr("checked") == true) {
                        var id = jQuery(this).attr("id");
                        if (jQuery("#inventoryNum" + id).val() <= 0) {
                            b = true;
                        }
                    }
                });
                if (b) {
                    alert("库存小于等于0不能销售");
                    return;
                }
                else
                    jQuery("#productDTOListForm").attr("action", "sale.do?method=getProducts&type=good");
            } else if (flag == 4) {
                jQuery("#productDTOListForm").attr("action", "txn.do?method=getProducts");
            }
            else {
                return;
            }
            jQuery("#productDTOListForm").submit();
        }
?