How to make PHP perform calculation immediately?

Hi there,

I have 2 items, A which is price ($) and B which is qty (units). I have a column C which is AB. What code shall I use in order to make C to calculate AB immediate and the answer appears on the screen, before I press “save” button?

Thank you.

You really would want a client-side language, such as JavaScript (I prefer JQuery library) to do what you’re wanting to accomplish. You could throw in a little Ajax and a server-side language (PHP), if the code gets where it requires a server-side database or application.

Here is a small HTML file that creates, displays and processes a small calculator.
It uses just HTML and Javascript. Simple and you can see how to make additions or
multiplication. Hope it helps…

Oh, remember, simpler is always the best way. I love to use AJAX and pull in a PHP file and
have it load into a

etc… But, to just multiply one field with one other field, JS is the simple way…

Hope it helps…
[php]

Calculator Example





[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service