Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 选中所有其他复选框时,保存时取消选中所有复选框_Jquery_Jsp - Fatal编程技术网

Jquery 选中所有其他复选框时,保存时取消选中所有复选框

Jquery 选中所有其他复选框时,保存时取消选中所有复选框,jquery,jsp,Jquery,Jsp,我有一个jquery方法来控制复选框事件 当我点击save时,我的“全选”复选框被取消选中。奇怪的是,当我在调试时放置断点时,我的“全部检查”复选框会被选中并保持选中状态 页面加载时调用的方法的代码: function checkIfAllCheckboxesSelected(){ var a = $("input[type='checkbox'].groupNames"); if(a.length !=0) { if(a.length == (a.fil

我有一个jquery方法来控制复选框事件

当我点击save时,我的“全选”复选框被取消选中。奇怪的是,当我在调试时放置断点时,我的“全部检查”复选框会被选中并保持选中状态

页面加载时调用的方法的代码:

function checkIfAllCheckboxesSelected(){
    var a = $("input[type='checkbox'].groupNames");
    if(a.length !=0)
    {
        if(a.length == (a.filter(":checked").length)){
           $('.allRecordsGroups').prop("checked",true);
        }
        else{
            $('.allRecordsGroups').prop("checked",false);
        }
    }   
} 
我的方法有问题吗?我调试了一切,没有其他事件被触发

这是我的保存方法。我在jsp中的save上调用此方法

<script>
   function saveForm(){
     $("#submitForm1").val("NO");
     $("#sfForm").submit();
   }  
</script>

函数saveForm(){
$(“提交格式1”).val(“否”);
$(“#sfForm”).submit();
}  
我的完整jsp页面是:

<div class="errMsg"><img src="http://www.equifax.com/fusion/images/cms/error-small.png" /></div>


  <h2 class="fusion-h3Title">New Sample File Setup <span class="fusion-Description">Complete the Required Information, and click 'Save' or 'Submit'.</span></h2>


      <span class="line"></span>
      <div class="clear"></div>
      <sf:form  action="/audit/savesfsetup?projectNumber=${project.projectNumber}" modelAttribute="sfForm" method="post">
      <div class="refineParam">
        <input type="hidden" name="projectNumber" value="${project.projectNumber}"/>
        <sf:input type="hidden" path="id" value="${sfForm.id}"/>
        <sf:input type="hidden" path="assignedId" value="${sfForm.assignedId}"/>
        <input type="hidden" id="svAcceptRecs"/>
        <input type="hidden" id="svRejectRecs"/>
        <label>Process name:${sfForm.assignedId}</label> <sf:input type="text" path="name" value="" cssClass="required" maxLength="30"/> <span class="italicsTxt">(Custom Name)</span> 
        <span class="line"></span>
        <div class="fileSummary">
        <!-- include for process/Job fulfillment data input fields -->
        <%@ include file="../../process-fulfillment-details-withGroups.jsp" %>
        <span class="line"></span>
        <div class="row">                        
        <label>Select All&nbsp;: &nbsp; &nbsp;</label>
          <sf:checkbox path="allRecords" id="allRecords"/>
        </div>
        <div class="row"> 
        <label>Records per Accept Level&nbsp;:&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;</label>
              <sf:input type="text" path="noOfAcceptRecs" />
        </div>

        <div class="row"> 
        <label>Records per Reject Level&nbsp;:&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</label>
              <sf:input type="text" path="noOfRejectRecs" />
        </div>
        </div>
        <br/>
        <div class="audit-sample">  
        <c:choose>
        <c:when test="${sfForm.holdForMove == 'Y'}">   
        <sf:checkbox path="holdForMove" value="Y" checked="checked"/>Hold for additional data append via Move Statements   
        </c:when>  
        <c:otherwise>
        <sf:checkbox path="holdForMove" value="Y"/>Hold for additional data append via Move Statements
        </c:otherwise>
        </c:choose>
        </div><br/>
        <span>        
        <sf:input type="hidden" path="submitForm" name="submitForm1" id="submitForm1"/>
        </span>
      </div>
      <br/>      
       <span class="line"></span>


          <div class="buttons">
            <a href="<c:url value="/audit/home?projectNumber=${project.projectNumber}"/>" class="orange-btn">&laquo; Back </a>
            <input type="button" value="Save"  onClick="saveForm()" class='orange-btn'/> 
            <input type="button" value="Submit &raquo;"  onClick="changeForm()" class='orange-btn'/>
         </div>
      </sf:form>


<script src="<s:url value='/resources'/>/js/cms_data_sf.js" type="text/javascript" language="javascript"></script>    
<script type="text/javascript">
    activateSelectedNav('#cms_project');
    activateTab('#audit');
</script>
<script>
   function saveForm(){
     $("#submitForm1").val("NO");
     $("#sfForm").submit();
   }

   function changeForm(){
     $("#submitForm1").val("YES");
     $("#sfForm").submit();
   }

</script>

新建示例文件设置完成所需信息,然后单击“保存”或“提交”。
进程名称:${sfForm.assignedId}(自定义名称)
全选:
每个接受级别的记录:
每个拒绝级别的记录:

通过Move语句附加额外数据的Hold 通过Move语句附加额外数据的Hold

激活选定导航(“cms”项目); 激活选项卡(“审计”); 函数saveForm(){ $(“提交格式1”).val(“否”); $(“#sfForm”).submit(); } 函数changeForm(){ $(“#提交格式1”).val(“是”); $(“#sfForm”).submit(); }
使用的js文件是:

$(document).ready(function(){

    $.validator.addMethod("unixFileName", function(value, element){
        return /^[a-zA-Z0-9_./-]+$/.test(value);
    });

    $.validator.addMethod("checkIfProcessDataChecked", function(value, element){

        if($("#submitForm1").val() == 'NO') { 
            return true;
        } 
        else {
            var selectedItem = "";
            $("#fromProcessId option").each(function(){
                if($(this).attr('selected') == 'selected') {
                    selectedItem = $(this).val();
                }
            });

            if(selectedItem == '0')
            {
                return false;
            }
            else return true;
        }

    });

    $.validator.addMethod("checkIfjobIdChecked", function(value, element){

        if($("#submitForm1").val() == 'NO') { 
            return true;
        } 
        else {
            var selectedItem = "";
            $("#fromProcessId option").each(function(){
                if($(this).attr('selected') == 'selected') {
                    selectedItem = $(this).val();
                }
            });

            if(selectedItem == '0') {
                return true;
            }
            else {

                $("#jobId option").each(function(){
                    if($(this).attr('selected') == 'selected') {
                        selectedItem = $(this).val();
                    }
                });

                if(selectedItem == "") {
                    return false;
                }
                else return true;
            }
        }

    });

    $.validator.addMethod("checkIfItemIdChecked", function(value, element){

        if($("#submitForm1").val() == 'NO') { 
            return true;
        } 
        else {
            var selectedItem = "";
            $("#fromProcessId option").each(function(){
                if($(this).attr('selected') == 'selected') {
                    selectedItem = $(this).val();
                }
            });

            if(selectedItem == '0') {
                return true;
            }
            else {

                $("#jobId option").each(function(){
                    if($(this).attr('selected') == 'selected') {
                        selectedItem = $(this).val();
                    }
                });

                if(selectedItem == "") {
                    return true;
                }
                else {
                    $("#itemTableId option").each(function(){
                        if($(this).attr('selected') == 'selected') {
                            selectedItem = $(this).val();
                        }
                    });

                    if(selectedItem == "") {
                        return false;
                    }
                    else return true;

                }
            }
        }

    });

    $.validator.addMethod("checkAcceptRecs", function(value, element){

        if($("#submitForm1").val() == 'NO') {
            return true;
        } 
        else if($('input[type="checkbox"]'.allRecords).is(':checked')) {
            return true;
        }
        else {
            var value = $("#noOfAcceptRecs").val();
            if(value != "" && !isNaN(value)) {
                return true;
            }
            else
                return false;
        }
    });

    $.validator.addMethod("checkRejectRecs", function(value, element){

        if($("#submitForm1").val() == 'NO') {
            return true;
        } 
        else if($('input[type="checkbox"]'.allRecords).is(':checked'))
        {
            return true;
        }
        else
        {
            var value = $("#noOfRejectRecs").val();
            if(value != "" && !isNaN(value))
            {
                return true;
            }
            else
                return false;
        }
    });

    var container = $('div.errMsg');
    $(document).ready(function() {
            $('#sfForm').validate({
               errorContainer : container,
               errorLabelContainer: container,
               rules:{
                name:{unixFileName: true},
                fromProcessId:{checkIfProcessDataChecked: true},
                jobId:{checkIfjobIdChecked: true},
                itemTableId:{checkIfItemIdChecked: true},
                noOfAcceptRecs:{checkAcceptRecs: true},
                noOfRejectRecs:{checkRejectRecs: true}
               },
               messages:{
                    name:"Please enter alpha-numeric process name.<br>",
                    fromProcessId:"Please select the input process.<br>",
                    jobId:"Please select the input Job Id for process selected.<br>",
                    itemTableId:"Please select the input item for process selected.<br>",
                    noOfAcceptRecs:"Please enter valid Accept records <br>",
                    noOfRejectRecs:"Please enter valid Reject records <br>"
               }
            });
     });

    $('#allRecords').change(function(event) {

        if($(this).is(':checked')) {

            $('#svAcceptRecs').val($('#noOfAcceptRecs').val());
            $('#noOfAcceptRecs').val("");
            $("#noOfAcceptRecs").attr('readonly','readonly');

            $('#svRejectRecs').val($('#noOfRejectRecs').val());
            $('#noOfRejectRecs').val("");
            $("#noOfRejectRecs").attr('readonly','readonly');
        }
        else {

            $('#noOfAcceptRecs').val($('#svAcceptRecs').val());
            $("#noOfAcceptRecs").removeAttr('readonly','readonly');

            $('#noOfRejectRecs').val($('#svRejectRecs').val());
            $("#noOfRejectRecs").removeAttr('readonly','readonly');
        }
    });


});
$(文档).ready(函数(){
$.validator.addMethod(“unixFileName”,函数(值,元素){
返回/^[a-zA-Z0-9./-]+$/.测试(值);
});
$.validator.addMethod(“checkIfProcessDataChecked”),函数(值,元素){
如果($(“#submitForm1”).val()=='NO'){
返回true;
} 
否则{
var selectedItem=“”;
$(“#fromProcessId选项”)。每个(函数(){
if($(this).attr('selected')=='selected'){
选择editem=$(this.val();
}
});
如果(selectedItem==“0”)
{
返回false;
}
否则返回true;
}
});
$.validator.addMethod(“checkIfjobIdChecked”,函数(值,元素){
如果($(“#submitForm1”).val()=='NO'){
返回true;
} 
否则{
var selectedItem=“”;
$(“#fromProcessId选项”)。每个(函数(){
if($(this).attr('selected')=='selected'){
选择editem=$(this.val();
}
});
如果(selectedItem==“0”){
返回true;
}
否则{
$(“#jobId选项”)。每个(函数(){
if($(this).attr('selected')=='selected'){
选择editem=$(this.val();
}
});
如果(selectedItem==“”){
返回false;
}
否则返回true;
}
}
});
$.validator.addMethod(“checkIfItemIdChecked”,函数(值,元素){
如果($(“#submitForm1”).val()=='NO'){
返回true;
} 
否则{
var selectedItem=“”;
$(“#fromProcessId选项”)。每个(函数(){
if($(this).attr('selected')=='selected'){
选择editem=$(this.val();
}
});
如果(selectedItem==“0”){
返回true;
}
否则{
$(“#jobId选项”)。每个(函数(){
if($(this).attr('selected')=='selected'){
选择editem=$(this.val();
}
});
如果(selectedItem==“”){
返回true;
}
否则{
$(“#itemTableId选项”)。每个(函数(){
if($(this).attr('selected')=='selected'){
选择editem=$(this.val();
}
});
如果(selectedItem==“”){
返回false;
}
否则返回true;
}
}
}
});
$.validator.addMethod(“checkAcceptRecs”,函数(值,元素){
if($(“#submitForm1”).val()==‘否’){
返回true;
} 
else if($('input[type=“checkbox”]'.allRecords).is(':checked')){
返回true;
}
否则{
var值=$(“#noofaceptrecs”).val();
如果(值!=“”&&!isNaN(值)){
返回true;
}
其他的
返回false;
}
});
$.validator.addMethod(“checkRejectRecs”,函数(值,元素){
if($(“#submitForm1”).val()==‘否’){
返回true;
} 
else if($('input[type=“checkbox”]'.allRecords).is(':checked'))
{
返回true;
}
其他的
{
var值=$(“#noOfRejectRecs”).val();
如果(值!=“”&&!isNaN(值))
{
返回true;
}
其他的
返回false;
}
});
var容器=$('div.errMsg');
$(文档).ready(函数(){
$('#sfForm')。验证({
errorContainer:container,
errorLabelContainer:容器,
规则:{
名称:{unixFileName:true},