將form表單中的元素轉(zhuǎn)換成對象的方法適用表單提交

字號:


    代碼如下:
    function serializeobject(form){
    var o ={};
    $.each(form.serializearray(),function(index){
    if(o[this['name']]){
    o[this['name']] = o[this['name']] +,+this['value'];
    }else{
    o[this['name']] = this['value'];
    }
    });
    return o;
    }