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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:26:43+00:00 2026-06-03T02:26:43+00:00

Please refer to the sample link first to understand my issue. first im dividing

  • 0

Please refer to the sample link first to understand my issue.

first im dividing a value and displaying each divided values into input text field.

you can see the sample here.. http://fahidmohammad.in/demo/sample/

in the sample link – – the total is the amount to be divided and number of installment is the number of split.

I know what you might be thinking…what exactly i need right??

Here comes the second stage of the process:

now i have the splits, what i need actually is, if i change the value form any of the splitted input the next value or the remaining should auto sum with the total amount.

eg…

Total Amount = 9000
Number of installment = 3

Split1 = 3000
Split2 = 3000
Split3 = 3000

if i decide to change split1 to 4000 then the remaining splits should auto sum.

eg..

Split1 = 4000
Split2 = 2500 [auto sum]
Split3 = 2500 [auto sum]

Mathematically i know the process but how do i accomplish this in jquery coz the number of splits may vary upon the user input.

What is the right method to follow???

  • 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-03T02:26:44+00:00Added an answer on June 3, 2026 at 2:26 am

    here’s what you need to do…

    i’d suggest to first start by adding elements like

    var numInst = $('input[name="ni"]').val();
    var total = $('input[name="ta"]').val();
    var payment = total / numInst;
    
    for(var i = 0; i < total; i++){
        $('<input/>').attr({
            'type' : 'text',
            'name' : 'sum[]'
        }).val(payment).addClass('installment').appendTo('#inner');
    }
    

    i’m freehanding this so give or take some errors…but that’s a much more efficient way to do it rather than appending strings as html.

    for your installment onchange event:

    $('.installment').change(function(){
        var numInst = $('input[name="ni"]').val();
        var total = $('input[name="ta"]').val();
        var otherPayment = (total - $(this).val()) / (numInst - 1);
    
        $(this).addClass('dontChange');
    
        $.each($('.installment'),function(i, val){
            if(!($(this).hasClass('dontChange')){
                $(this).val(otherPayment);
            }
        });
    
        $(this).removeClass('dontChange');
    });
    

    like i said, i freehanded all this, but i think the logic is solid. just add a class to the one that was manually changed temporarily, then loop through the installment class text boxes and change the value to equal the total, minus the value that was manually entered, divided by 1 less payment that what ni equals.

    the only problem i might foresee is that without setting a flag to those boxes that have been manually changed, any changes will be overwritten if the user changes another installment boxes.

    easy fix would be to move the $(this).removeClass(‘dontChange’); line from the installment onchange function to the end of your ni and ta onchange handler. just change $(this) to $(‘.installment’)

    hope it helps!

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

Sidebar

Related Questions

Please refer my previous question for code sample Sockets: sometimes (rarely) packets are lost
Please refer to this post. I have become able to configure my web.config file
Please refer to this background question. After constructing this COUNT, how would I then
Please refer my previous post here . I did changes accordingly but getting error.
Please refer to the topic http://www.codeproject.com/KB/viewstate/SaveViewState.aspx . The topic demonstrates how you can save
Please refer to Get PDF hyperlinks on iOS with Quartz It explained an algorithm
How does the toggle button on mootools rte work, please refer to example on
How to build exe files from py files (compatible with win32)? please don't refer
please let me know a java multithread application which i can refer ( source
I have the following models which basically refer to Lessons and Categories. Each lesson

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.