0

我在更改下拉选项时提交表单。提交表单后我重定向到同一页面。我使用以下功能提交表单:

function submitform(){
    //Below variables are checkbox value
    var addresscheck = $('#addressmatchedCheck').is(':checked');
    var rcnumbercheck =  $('#rcnumbermatched').is(':checked');
    var phonenumbercheck = $('#phonenumbercheck').is(':checked');
    var idproofcheck = $('#idproofcheck').is(':checked');
    var guarantoraddresscheck = $('#guarantoraddressmatchedCheck').is(':checked');
    var guarantoridcheck = $('#guarantoridproofcheck').is(':checked');
    var guarantorrelationcheck = $('#guarantorrelationshipCheck').is(':checked');
    if( addresscheck &  rcnumbercheck & phonenumbercheck & idproofcheck  & guarantoraddresscheck & guarantoridcheck & guarantorrelationcheck) {
                $('#statusid').val(1);
                alert($('#statusid').val() + "if");
    }
    else{
        $('#statusid').val(2);
        alert($('#statusid').val() + "else");
    }
    $('#fieldVerificationFormID').attr('method', 'POST'); 
    $('#fieldVerificationFormID').attr('action', '/mfi/api/1.0/client/ci/groups/member/fieldverification/insert');
    $('#fieldVerificationFormID').submit();
} 

我的问题是复选框即使被选中也只返回错误?第一次,即在表单提交之前它完全正常。问题是在表单提交之后。谁能解决我的问题?

4

2 回答 2

0

如果你这样命名你的复选框,它会起作用:

<input type="checkbox" id="addressmatchedCheck" checked="checked" />
<input type="checkbox" id="rcnumbermatched" checked="checked" />
<input type="checkbox" id="phonenumbercheck" checked="checked" />
<input type="checkbox" id="idproofcheck" checked="checked" />
<input type="checkbox" id="guarantoraddressmatchedCheck" checked="checked" />
<input type="checkbox" id="guarantoridproofcheck" checked="checked" />
<input type="checkbox" id="guarantorrelationshipCheck" checked="checked" />

演示:http: //jsfiddle.net/Guffa/DqdgC/

于 2012-10-13T10:06:49.033 回答
0

这就是我使用的。我有一个用 isChecked() 函数扩展 JQuery 的函数。我很久以前在选择器中使用 :checked 之前做了这个。但它非常防弹。

jQuery.fn.isChecked = function() {
    var isChecked = false;
    this.each(function(){
        if (this.checked) {
            isChecked = true;
            return;
        }
    });
    return isChecked;
}

function check() {
    var addressCheck = $('#addressmatchedCheck').isChecked();
}
于 2012-10-13T09:41:59.643 回答