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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:14:59+00:00 2026-05-21T20:14:59+00:00

I have a system that is tracking volunteers for a performing arts center. When

  • 0

I have a system that is tracking volunteers for a performing arts center. When they sign up to work a shift they can also sign up a buddy (or buddies). There’s also a waiting list if we have too many sign-ups. The form looks like so for selecting buddies:

enter image description here

If the waiting list only has one position left on it I need to turn the next person’s name red if they are selected (so John is selected, but when Jane is checked she turns red to serve as a warning).

My problem is that the user might decide to check them both, then uncheck John instead of Jane, which should then make Jane turn black again.

Is there an easy way to track clicks using something like:

$("input:checkbox").change(function(){

    $("input:checked").each(function(i){

       //object/array manipulation?

    });

});

I had it working okay using the index of the element but realized that wouldn’t work since it would keep track of the order in which the checkboxes were checked in the first place.

Even a point in the right direction would be amazing. I realize I haven’t given much to go on.

Thanks,

Jason

  • 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-21T20:15:00+00:00Added an answer on May 21, 2026 at 8:15 pm

    Nice challenge. You could do this:

    var limit = 4;  //Maximum checked allowed, for example 4
    var checkedOrder = []; //Priority queue (stores checking order)
    $("input:checkbox").change(function(){
        var nCurrentlyChecked = $("input:checkbox:checked").length; // EDIT: How many are currently checked?
        if($(this).is(":checked")){ //If checkbox is checked
            checkedOrder.unshift(this); //Insert to the begining of the array (push to the queue)
            if(nCurrentlyChecked > limit) //If more than allowed
                $(this).next().css('backgroundColor', 'red'); //Turn element red
        }else{ //If checkbox is unchecked
            $(this).next().css('backgroundColor', 'black'); //Always blacken unchecked checkbox
            var nTurnedBlack = 0;
            //Now, we blacken checkboxes by priority
            for(var i=0; i<checkedOrder.length && nTurnedBlack <= limit; i++){           
               var checkbox = checkedOrder[i];
               if(checkbox == this) continue; //Ignore currently unchecked checkbox
               $(checkbox).next().css('backgroundColor', 'black'); 
               nTurnedBlack++;
            }
        }
    });
    

    As you can see, it has a ‘preference’ to blacken checkboxes that have been checked first. This is not tested code, and may have errors, but i hope it guides you to your final solution

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

Sidebar

Related Questions

I have a system that creates an order and that order can be billed
Here is my problem. I have a ticket-tracking system that is not very 'user
I have an issue whereby the company uses a business tracking system that captures
I am building a location tracking system for one of our client. They have
We have system here that uses Java JNI to call a function in a
I have a system that needs to send and receive data over an insecure
I have a system that combines the best and worst of Java and PHP.
I have a system that uses a meta refresh to a logout page, which
I have a system that takes dynamic data, puts it in HTML for layout
I have big system that make my system crash hard. When I boot up,

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.