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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:20:22+00:00 2026-06-06T17:20:22+00:00

I have a web form with a bunch of checkboxes; when a specific box

  • 0

I have a web form with a bunch of checkboxes; when a specific box is clicked, it shows/ hides a specific div with more data in it. When the divs are properly hidden/ shown, I run a formatting command to organize and color them properly.

Some checkboxes are dependent on others, and a cascading scheme will be implemented, so it is possible, even likely, that several checkboxes will be changing state at one go.

Instead of writing code for each checkbox, I decided to take a shortcut and handle all the checkboxes the same way. I ended up like so (using 2 checkboxes/ divs to make the point, there’s a bunch more):

jQuery(document).ready(function () {

    alternateDivs();

    jQuery('#AccessCAS, #CAS_LELOCSpecific').on('click', function () {
        showHide();
    });

});

function showHide() {

    var theChecks = [
        {
            checkId: 'AccessCAS',
            divId: 'divCAS'
        },
        {
            checkId: 'CAS_LELOCSpecific',
            divId: 'divLELOC'
        }
    ];

        var pendingChanges = 0;

    for (i = 0; i < theChecks.length; i++) {
        var checked = jQuery('#' + theChecks[i].checkId).is(':checked');
        var visible = jQuery('#' + theChecks[i].divId).is(':visible')
        if (checked && !visible) {
            pendingChanges++;
            jQuery('#' + theChecks[i].divId).fadeIn(400, function () {
                pendingChanges--;
            });
        } else if (!checked && visible) {
            pendingChanges++;
            jQuery('#' + theChecks[i].divId).fadeOut(400, function () {
                pendingChanges--;
            });
        }
    }
//check for pending changes

}

function alternateDivs() {
    jQuery('.formTable:visible:odd').css('background-color', '#eeb');
    jQuery('.formTable:visible:even').css('background-color', '#eef');
}

It’s necessary for me to make sure all the divs that are supposed to show will show properly, which means they must be fully transitioned to their visible/ not visible state before calling alternateDivs(). You can see I set up a pendingChanges value to be incremented and decremented as the divs are transitioned.

What I’d like to do is set up an asynchronous process to check for when pendingChanges equals zero, and when that happens to invoke alternateDivs(). I want this to be asynchronous so that it does not interfere with the user experience.

I believe this can be done through some sort of callback, but this is well out of my expertise area. How would I set up and invoke an asynchronous function to check to make sure my other asynchronous functions are completed, and when they are to call another function and exit?

I hope that’s clear.

  • 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-06T17:20:24+00:00Added an answer on June 6, 2026 at 5:20 pm

    How about putting an if statement in your fade callbacks?

    if(pendingChanges==0){ alternateDivs() }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a bunch of numbered fields in a web form, like an
I have a web form used for importing data from a CSV file. It
I have web search form, When i submit my search in the search box,
I have a web form, that needs to save the data that the user
I have a web form in asp.net. I load the data on the page
I have web form with a panel which has form elements in side it.
I am running a thread in C#. I have web form. I declared public
I have a web form with some TextBoxes and CheckBoxList . I want to
I have a web form that inserts a row into an SQL Server 2008
i have a web form and i want to change its titles for each

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.