View Single Post
Old 02-21-2013, 05:32 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You can't do that with PHP in a web environment. HTTP is stateless and PHP is a server side language, so it only works on request and response. You can use AJAX for that, but if you're doing that anyways you may as well put the burden entirely on the JS for the calculations.
What you can do is keep track of the sum and pass it through a hidden field on the form. Then you can keep self submitting the form and so long as the sum is > 0, you simply provide only one field to add to it, otherwise you give two fields to add together.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
sssunny (02-22-2013)