RE: [PHP-WIN] PHP/Javascript
| From: | Mike Flynn | Date: | Sat, 19 May 2001 16:06:53 +0000 |
| Subject: | RE: [PHP-WIN] PHP/Javascript | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-7757@lists.php.net to get a copy of this message | ||
Good point. I personally do that every time -- I never rely on client-side script-produced values, I just use them for aesthetics -- so the user can see the changes right before their eyes before submitting. But if you say have 3 fields, A B and C where C is A*B, I will have PHP recalculate C upon submission even though the JavaScript may have set C to A*B beforehand.
Take care,
-Mike
At 04:20 PM 5/19/01 +0100, you wrote:
One little warning, even if you are doing your calculations in javascript, do them again in PHP and check the two are correct. Somebody on the client-side could alter the data going into the PHP-script. I always think it's dangerous when people start using Javascript - what happens if the client has no javascript - are you going to detect that. Yours Mr. Adam ALLEN. adam@dynamicinteraction.co.uk http://www.dynamicinteraction.co.uk You can either have the user change values, then hit the "recalculate" or "update" button which calls the PHP script to update all values.. or you can use JavaScript to update some simple calculations immediately after the user makes any changes, but you still need to have them eventually submit it to actually record the changes anywhere meaningful -- i/e database, file, session/cookie, etc. A nice combination of both is the most aesthetic. For example, say you had a form with 3 inputs:[item price] [quantity] [subtotal]It would be nice to have the JavaScript update subtotal any time the user changes the item and/or quantity, to reflect the new subtotal. But you would still need them to submit the form for PHP to take note of the submitted data and do whatever. -Mike At 07:55 AM 5/19/01 -0500, you wrote:This is what my screen looks like:[text box]I want to order ... description image dropdown box @ 7.95 each =number andcontaining 0-20 numericsI had been contemplating using Javascript to perform the text box extension of the quantity * rate calculation. However, the need is to also update a MySQL table with the session trackingother pertinent information about the selection so a purchase order can be written in a subsequent module. Can this be done with straight PHP or will it require a mix ofJavascriptfor the calculation and PHP for the data base update? If so, what might the code look like? Bob -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net-=- Mike Flynn - Burlington, VT -=-mike@mikeflynn.net http://www.mikeflynn.net/ * Give blood * Wouldn't the free market, in its true form, be anarchy? -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-=- Mike Flynn - Burlington, VT -=-mike@mikeflynn.net http://www.mikeflynn.net/ * Give blood * Wouldn't the free market, in its true form, be anarchy?