从存储的数组中检索复选框

时间:2016-05-28 12:48:04

标签: jquery html

我有这个功能,我想创建另一个函数来再次检索模型上的复选框数组(USER_CARD_DECLARE_DATA_List)

userobj.SaveDeclarationForm = function ()
{
    var USER_CARD_DECLARE_DATA_List = []
    $(".option").map(function () {
        var USER_CARD_DECLARE_DATA = {}
        if ($(this).find(".RESULT_VAL")[0].checked == true) {
            USER_CARD_DECLARE_DATA.RESULT_VAL = 1;
        }
        else {
            USER_CARD_DECLARE_DATA.RESULT_VAL = 0;
        }
        USER_CARD_DECLARE_DATA_List.push(USER_CARD_DECLARE_DATA);
    })
    $('#myModal').modal('hide');
    userobj.declaration = USER_CARD_DECLARE_DATA_List;
}

1 个答案:

答案 0 :(得分:0)

更改

var USER_CARD_DECLARE_DATA_List = []

为:

var USER_CARD_DECLARE_DATA_List = this.USER_CARD_DECLARE_DATA_List = []

现在,您可以使用userobj的其他方法访问数组:

this.USER_CARD_DECLARE_DATA_List