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 8926813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:04:18+00:00 2026-06-15T08:04:18+00:00

I have 2 main checkboxes ja and nee. When one of these checkboxes is

  • 0

I have 2 main checkboxes “ja” and “nee”. When one of these checkboxes is checked it opens up a submenu that has 1 or more checkboxes. These subcheckboxes are also “ja” and “nee” and respond to the choice made in the maincheckbox. The problem I’m having is that the user can choose “nee” in the main checkbox and then change all the subcheckboxes to “ja” but then the maincheckbox stays at “nee” but it has to switch to the “ja” checkbox.

I’ve made it so that the questions only have 2 checkboxes and only on the them can have a checked attribute and the subcheckboxes are in a div class called “submenu”.

What I think the solution to this problem is to check if any of the “nee” class subcheckboxes is checked in the submenu. If it is the maincheckbox stays at “nee” else remove the checked attribute from the “nee” maincheckbox and switch it to the “ja” checkbox. But obviously I can’t figure out how to do that.

I made small jsFiddle showing the project: http://jsfiddle.net/B2zs5/

<div>
<p>Heb je DigiD?</p>
                <div class="antwoorden">
                    <input id="ja" type="checkbox" value="ja" class="sub_antwoord ja"/><label for="ja">Ja</label>
                    <input id="nee" type="checkbox" value="nee" class="sub_antwoord nee"/><label for="nee">Nee</label> 
                    <div class="extra_info">?
                        <div class="extra_info_popup">
                            Hidden tekst
                        </div>
                    </div>
                </div>
            </div>

And here’s the jQuery code

    $('.open_sub_ja').click(function () {
    $(this).parents('.container_vragen').find('.ja').attr('checked', this.checked);
    $(this).parents('.container_vragen').find('.nee').removeAttr('checked');
});

$('.open_sub_nee').click(function () {
    $(this).parents('.container_vragen').find('.ja').removeAttr('checked');
    $(this).parents('.container_vragen').find('.nee').attr('checked', this.checked);
});

    $('.ja').click(function () {
        $(this).parents('.antwoorden').find('.ja').attr('checked', this.checked);
        $(this).parents('.antwoorden').find('.nee').removeAttr('checked');
    });

    $('.nee').click(function () {
        $(this).parents('.antwoorden').find('.ja').removeAttr('checked');
        $(this).parents('.antwoorden').find('.nee').attr('checked', this.checked);
    });

If I were to guess it would be something like this,

  if('.nee'.attr('checked')) {
    // do nothing
} 
else {
    $('.open_sub_nee').removeAttr('checked');
    $('.open_sub_ja').attr('checked');
}
  • 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-06-15T08:04:20+00:00Added an answer on June 15, 2026 at 8:04 am

    I’m guessing you want main nee > all sub’s ja > set the main to ja and vice versa to have main ja change to nee when 1 or more sub’s are nee.

    the second bit is easy:

    $('.nee').click(function () {
        $(this).parents('.antwoorden').find('.ja').removeAttr('checked');
        $(this).parents('.antwoorden').find('.nee').attr('checked', this.checked);
    
        $(this).parents('.container_vragen').find('.open_sub_ja').removeAttr('checked');
        $(this).parents('.container_vragen').find('.open_sub_nee').attr('checked', this.checked);
    });
    

    it seems to have saved my edit in http://jsfiddle.net/B2zs5/2/

    all checkboxes in the submenu to ja changes the main nee to ja:
    http://jsfiddle.net/B2zs5/5/ – I’ve used Teun’s code and Determine if all checkboxes within jQuery object are checked, return as boolean

    $('.ja').click(function () {
        $(this).parents('.antwoorden').find('.ja').attr('checked', this.checked);
        $(this).parents('.antwoorden').find('.nee').removeAttr('checked');
    
        $group1 = $(this).parents('.submenu').find('.ja');
        if( $group1.filter(':not(:checked)').length === 0){
            //ALL ja checkboxes in submenu checked
            $(this).parents('.container_vragen').find('.open_sub_ja').attr('checked', this.checked);
            $(this).parents('.container_vragen').find('.open_sub_nee').removeAttr('checked');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my main form (form1) I have checkboxes that when checked should also check
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
I have a one main jsp (file upload jsp screen) which has form elements.
I have a column that holds Checkboxes. My main problem is that when I
I have main window which has inner grid components. When I press a button
i have main activity in which i have Four menus. and i have one
I have main.cpp (including main function) and func1.cpp, and I want to link these
Splash I have main activity UI startup operations that take between 5-10 seconds (that
I have a main-section div that is set to inherit it's height from its'
I have a bunch of checkboxes, that I'd really like to make the user

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.