码迷,mamicode.com
首页 > Web开发 > 详细

json function

时间:2014-09-29 20:00:41      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:io   os   ar   for   数据   sp   c   on   cti   

    //保存商品属性
        function Attributesnext()
        {
            //循环获取属性集值和属性文本框值后保存到数据库的Json
            var attributesInfo = "[";
            var data = $("#hideattributesInfo").val();
          
         
            data = data.substr(0, data.length - 1);
            var arr0 = data.split(‘;‘);
            for (var i = 0; i < arr0.length;i++)
            {
                var arr1 = arr0[i].split(‘:‘);
                var AttributeSetsID = arr1[0];
                attributesInfo = attributesInfo + "{\"AttributeSetsID\":"+"\""+ $("#tableSkuAttributes").find

("#td"+AttributeSetsID).attr("value")+"\",";
                attributesInfo = attributesInfo + "\"AttributeSetsValues\":" + "\"" + $("#tableSkuAttributes").find("#td" +

AttributeSetsID).html() + "\",";
                attributesInfo = attributesInfo+   "\"children\":[" ;
                var arr2 = arr1[1].split(‘,‘);
                for (var j = 0; j < arr2.length;j++)
                {

                    var AttributeID = arr2[j];
                    attributesInfo = attributesInfo + "{\"AttributeID\":" + "\"" + $("#tableSkuAttributes").find("#txt" +

AttributeID).attr("value1") + "\",";
                    // attributesInfo = attributesInfo + "\"AttributeValues\":" + "\"" + $("#tableSkuAttributes").find("#txt" +

AttributeSetsID).val() + "\",";
                    attributesInfo = attributesInfo + "\"AttributeValues\":" + "\"" + $("#tableSkuAttributes").find("#txt" +

AttributeID).val() + "\"},";
                   
                }
                attributesInfo = attributesInfo.substr(0, attributesInfo.length - 1);
                attributesInfo = attributesInfo + "]},"
              
            }
            attributesInfo = attributesInfo.substr(0, attributesInfo.length - 1);
            attributesInfo = attributesInfo + "]";
            $.post("../Handler/AddGoods.ashx?type=SaveAttribut&GoodsCode=" + $("#GoodsCode").val() + "&GoodsVersions=" +

$("#GoodsVersions").val() + "&PackingList=" + $("#PackingList").val(), { Introduction: aa }, function (data) {
                var result = $.parseJSON(data);
                //    alert(data.d);
                if (result == "1") {
                    window.location.href = "GoodsManage.aspx";
                } else {
                    top.Dialog.alert("操作失敗");
                }
            })
            alert(attributesInfo);
          
        }

json function

标签:io   os   ar   for   数据   sp   c   on   cti   

原文地址:http://www.cnblogs.com/zhangweixin/p/4000637.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!