Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:19:50+00:00 2026-05-26T22:19:50+00:00

I have 3 checkboxes with the following jQuery and it works great. $(document).ready(function() {

  • 0

I have 3 checkboxes with the following jQuery and it works great.

$(document).ready(function() {
    var $finishBoxes = $('#co1,#co2,#co3');
    $finishBoxes.change(function(){
        // check if all are checked based on if the number of checkboxes total
        // is equal to the number of checkboxes checked
        if ($finishBoxes.length == $finishBoxes.filter(':checked').length) {
            $('#submit2pd').attr("disabled", false);
        }
        else{
            $('#submit2pd').attr("disabled", true);
        }
    });

    $finishBoxes.ready(function(){
        // check if all are checked based on if the number of checkboxes total
        // is equal to the number of checkboxes checked
        if ($finishBoxes.length == $finishBoxes.filter(':checked').length) {
            $('#submit2pd').attr("disabled", false);
        } 
        else{
            $('#submit2pd').attr("disabled", true);
        }
    });
});

I want to add the following select option to the if statement so if all 3 are checked and the checkbox value=1 (yes) then the $(‘#submit2pd’).attr(“disabled”, true);

<select name="tcaccept" id="tcaccept"> 
    <option value="0"<?php if($mychecklist->tcaccept==0) echo 'selected' ?>>No</option>
    <option value="1"<?php if($mychecklist->tcaccept==1) echo 'selected' ?>>Yes</option>
</select>

Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:19:50+00:00Added an answer on May 26, 2026 at 10:19 pm

    Here some proper code:

    if ( ( $finishBoxes.length == $finishBoxes.filter(':checked').length ) && ( $('#tcaccept').val() == '1' )) {
    
        $('#submit2pd').prop("disabled", false);
        // $('#submit2pd').attr("disabled", "");
    
    
    }else{
    
        $('#submit2pd').prop("disabled", true);
        //$('#submit2pd').attr("disabled", "disabled");
    }
    

    If you are using jquery 1.6+, it’s better to use .prop() for special attributes like disabled (or checked …).


    Edit according to the comments:

    <form>
        <input type="checkbox" id="col1" /><label for="col1">Checkbox 1</label>
        <input type="checkbox" id="col2" /><label for="col2">Checkbox 2</label>
        <input type="checkbox" id="col3" /><label for="col3">Checkbox 3</label>
        <select id="tcaccept">
            <option value="0">No</option>
            <option value="1">Yes</option>
        </select>
        <input type="submit" text="Submit" id="SubmitButton" />
    </form>
    

    To cancel the form submition, simply return false;:

    $('#SubmitButton').click(function(event) {
        var $finishBoxes = $('#co1,#co2,#co3');
    
        if (!($finishBoxes.length == $finishBoxes.filter(':checked').length && $('#tcaccept').val() == '1' )) {
            alert('Check all the boxes and select "Yes"');
            return false;
        }
    
        // otherwise the form is submitted
        alert('Form will be submitted');
    
    });
    

    I’ve created a jsfiddle for you to play with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: $(document).ready(function () { $(tr).live('click',function(){ alert(TR); }); $(input).live('click',function(){ alert(INPUT); });
I have the following jquery code which works fine. $('#onlyTwo').click(function() { $(#textarea3).attr(disabled, true); $(#textarea4).attr(disabled,
I have the following two code blocks. Code block 1 var checkboxes = $(div.c1
I have the following using jQuery: var x = $('.boxes > input:checked'); From x
I have the following jQuery code to make my checkboxes act like radio buttons,
I have the following HTML/jQuery code where my CheckAll process box works fine but
I have the following jQuery code: <script> function hideMenteeQuestions() { $(#menteeapp).hide(); $(textarea[name='short_term_goals']).rules(remove, required); $(textarea[name='long_term_goals']).rules(remove,
I have a created a following renderer which renders the JTree with checkboxes and
I have the following jQuery script to transform a checkbox into a jQuery-UI button
In my jquery i have the following code, which for some reason is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.