We help IT Professionals succeed at work.
Get Started

How can I calculate values of fields and update the db without leaving or refreshing the PHP page?

sasnaktiv
sasnaktiv asked
on
213 Views
Last Modified: 2020-02-29
How can I calculate values of fields and update the db without leaving or refreshing the PHP page?

Boy do I need help! I've been struggling with this for far too long.
The frustrating thing about it is that I know there's a simple solution because I've done it before -- but I can't find my old code.
So I'm reaching out to guys who know this stuff much better than I do.

I'm merely trying to subtract a value of one field from the value of another field, then inserting the results into a third field, and updating the database -- without leaving or refreshing the page.

Below is a simple example of what it is I'm trying to accomplish.
Any help is greatly appreciated.
Sas

<INPUT type=text readonly='readonly' name='[b]AmountBILLED[/b]' value='[b]$AmountBILLED[/b]'> 
[i]NOTE: The value of field '[b]AmountBILLED[/b]' is harvested from a database [/i]

<INPUT type=text name='[b]AmountPAID[/b]' > 
[i]  The value of field '[b]AmountPAID[/b]' is entered by the end user [/i]

[i]  On Focus or Click of a (CALCULATE button) do the math - subtract the value entered in '[b]AmountPAID[/b]' from the value of '[b]AmountBILLED[/b]' and
 insert that value into the '[b]AmountDUE[/b]' field automatically, and UPDATE the db [/i]

<INPUT type=text readonly='readonly' name='[b]AmountDUE[/b]'  value='[b]$AmountDUE[/b]'>
[i] Another option to updating the value of [b]AmountDUE[/b] is to merely do so as a variable that is not in an <INPUT field. [/i]
[i] Thank the Expert who made my life a little easier  [/i]

Open in new window


PS: I don't know why but the BOLD and ITAL tags which I used for emphasis do not seem to be functioning properly on EE
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2020
Most Valuable Expert 2018
Commented:
This problem has been solved!
Unlock 7 Answers and 54 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE