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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:15:19+00:00 2026-06-16T07:15:19+00:00

So i’ve got 3 textfields (A, B, C) where the user can only enter

  • 0

So i’ve got 3 textfields (A, B, C) where the user can only enter numbers as the keyboard is a number pad.

I’ve got a check (which a user here sorted out for me) that brings up an error if the user tries to enter more than 100 in each box.

I need a method that looks at the number entered in the textfield and then looks at the total of the 3 and then adjusts the others accordingly.

An example would be say i typed the following:

Example 1
A = 50
I would expect B to fill in with the remaining 50

Example 2
A =40 B=50 C=10

I then change A to 60. The total is now 120.
I would like it to look at B, then take 20 away so I have the following.
A=60 B=30 C=10

I’ve seen scenarios where a user has 2 textfields that he wants to total 100 but I have not seen threads that ask for 3.

Thanks

  • 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-16T07:15:20+00:00Added an answer on June 16, 2026 at 7:15 am

    Let’s say you have three fields. This is pseudocode. Attach this delegate function to all 3 text areas.

    // Take 3 fields
    FieldA, FieldB, FieldC
    
    // Total target to reach
    TotalTarget = 100
    
    // The total we currently have
    total = FieldA + FieldB + FieldC
    
    // Work out how much we are under by. 
    // If positive, we are under. If negative, we are over.
    underBy = TotalTarget - total
    
    // Now two variables for the 'other two' fields.
    if sender == FieldA:
      other1 = FieldB, other2 = FieldC
    if sender == FieldB:
      other1 = FieldA, other2 = FieldC
    if sender == FieldC:
      other1 = FieldA, other2 = FieldB
    
    // Split the difference and assign to other 2 fields so they are raised or lowered the same amount.
    // If under, add, if over, subtract.
    other1 = other1 + overBy / 2
    other2 = other2 + overBy / 2        
    
    // This will add 1 or 0 to other2 (i.e. compensate for round-down)
    other2 = other2 + overBy % 2;
    

    If you use integer division, then you will have a rounding problem. Hint: if it’s odd, you can add one to one of the fields.

    Make sure you write tests. I’ve not tried any of this, but it should work.

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

Sidebar

Related Questions

I have an array which has BIG numbers and small numbers in it. I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.