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.
>[EMAIL PROTECTED]
>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:
> > >
> > >                                   I want to order ...
> > >description     image    dropdown box              @ 7.95 each =
> > [text box]
> > >                                   containing 0-20
> > >                                   numerics
> > >
> > >I 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 tracking
> > number and
> > >other 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 of
> > Javascript
> > >for 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: [EMAIL PROTECTED]
> > >For additional commands, e-mail: [EMAIL PROTECTED]
> > >To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> >                -=- Mike Flynn - Burlington, VT -=-
> > [EMAIL PROTECTED]  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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >


               -=- Mike Flynn - Burlington, VT -=-
[EMAIL PROTECTED]  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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to