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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:47:03+00:00 2026-06-04T21:47:03+00:00

Here: http://jsfiddle.net/justeric/AWC4U/4/ checking a box will sum all entries in the textfield column and

  • 0

Here: http://jsfiddle.net/justeric/AWC4U/4/ checking a box will sum all entries in the textfield column and subtract that sum from 100, then it will place the difference in the corresponding textfield. So if 20 is the sum of all entries in the textfield column, checking a checkbox will result in 80 (100-20) being populated in the corresponding textfield. This feature works correctly but here’s my problem:

If I uncheck a checkbox the corresponding textfield should return to a zero value without affecting any other textfields. So in the above example the 80 should return to 0 without changing the 20. Also every additional checkbox that is checked should return the new sum of the textfields, including whatever was populated from the last check, right now, the first calculation just keeps repopulating for each additional checkbox that is checked. So if the sum of the checkboxes is 20 and I check a checkbox 80 is populated in the corresponding textfield and that is correct but if I check another checkbox 80 is populated again but that is wrong now 0 should be populated because 100-20-80 = 0.

EDIT IN:

So to make the textfield corresponding to the checkbox clear without affecting the other fields requires something like:

$('.textfield').val(function() {
    if($('#' + this.id.replace(/textfield/,'checkbox')).is(':unchecked')){
return 0;}

This would affect all unchecked checkboxes but I want it only to work if a checked checkbox changes to unchecked. So the value reverts back to 0 in an intuitive manner without affecting any other textfields associated with an unchecked checkbox

  • 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-04T21:47:06+00:00Added an answer on June 4, 2026 at 9:47 pm

    Assuming you have a class on the checkboxes you can do something like the following:

    $('.checkbox').not(':checked');

    So in the change or click handler you could do:

    $('.checkbox').click(function() {
       if ($(this).not(':checked')) {
         // it is unchecked so do your uncheck function
         doUncheckSumFunction();  // you'd define this do what you need it to do
    
         } 
    });
    

    You could also define an uncheck function like this:

    $('table').on('unchecked', '.checkboxes', function() {
    // do the code you want done
    });
    

    Then in the first example instead of doUnCheckSumFunction() you can now do:

    $(this).trigger('unchecked');
    

    Update:

    To loop over a set of elements and do something you can do this:

    var $textareas = $('.textclass');
    
    var sum = 0;
    $('.checkbox').each(function(i) {
       if ($(this).not(':checked')) {
         sum = sum + 1;
         // or
         $textareas[i].val(0); //etc
       }
    });
    

    etc.

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

Sidebar

Related Questions

my code here http://jsfiddle.net/GKZRU/14/ all js working properly, and add/remove css classes(checking this in
All of this is code is here: http://jsfiddle.net/yrgK8/ I have a news section which
Ok, if you go here: http://jsfiddle.net/RarFB/2/ You will see the work that I have
I have this code here http://jsfiddle.net/RzBeM/65/ you will see two input fields called quantity.
The implementation is here: http://jsfiddle.net/chp8y/1/ If you hover over the first box, #1, you
EDIT My jsfiddle entry is here : http://jsfiddle.net/ehNrE/3/ All the codes(only those required) below
Fiddle here: http://jsfiddle.net/F6nJu/ I have a colored box: <div id=colorblock></div> #colorblock { background:#3ff; width:
I have a fiddle here: http://jsfiddle.net/maniator/SZpkF/1/ The green box is supposed to move with
I have Tabbed Navigation here: http://jsfiddle.net/EghAt/ When I click Tab 1 it outputs all
Example here: http://jsfiddle.net/KyW6c/2/ I have an ordered list. Each list item is a project

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.