troubleshooting Question

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

Avatar of sasnaktiv
sasnaktivFlag for United States of America asked on
DatabasesPHP
54 Comments7 Solutions217 ViewsLast Modified:
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]

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
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 7 Answers and 54 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 7 Answers and 54 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros