获取Form表单数据

HTML代码 

 JS代码

        var oD = Object.create(Object.prototype);;
        var sellOrderDetails = [];
        var frmArr = $('#frm').serializeArray();
        for (var i in frmArr) {
            oD[frmArr[i].name] = frmArr[i].value;
        }
        var $trArr = $('#tbody_details tr');
        var temp = Object.create(Object.prototype);
        for (var i = 0; i < $trArr.length; i++) {
            temp = Object.create(Object.prototype);
            var inpArr = $($trArr[i]).find("input");
            for (var k = 0; k < inpArr.length; k++) {
                var $inp = $(inpArr[k]);
                temp[$inp.attr("name")] = $inp.val();
            }
            sellOrderDetails[i] = temp;
        }
        oD.sellOrderDetails = sellOrderDetails;

JSON数据 

{
    "nn":"",
    "sellOrderDetails":[
        {
            "n1":""            
        },
        {
            "n2":""
        }
    ]
}

 

 

你可能感兴趣的:(获取Form表单数据)