Automatically Caculate Using Php?

Can you automatically calculate using PHP?

For instance:

Let’s say I have a basic form input:

<input id=“basic” name=“basic” size=“5”>

Upon putting a number in there it automatically calculates a sum total without using a post or get form. So basically, someone types in an integer above. In real time php caculates the number typed in a forumla:

basic - 12 =

If you want to use PHP to compute the basic value without submiting a form, you will need to use AJAX for that. AJAX will allow you to make a HttpRequest to your PHP script to retrieve the computation result that you can set on your “basic” input field.

They are not the commands actually they are the events occurred on the elements. Consider the following example just to alert:


<input type="text" name="txt1" id="txt1" onblur="alert(this.value);" />

This will alert the entered value when you go out from the text box. In this way you can call a function onblur or any other events and do the needful in the function. For more google and see some other examples.

How can you integrate onKeyPress, KeyDown, onBlur commands with php?

PHP does not do anything “in real time”. You’re describing client-side coding, which is most often Javascript.

Yes but for that also you need to have an event to trigger the ajax call.

What do you mean by calculate automatically? I could not understand what exactly you want to do with that value entered in the text box. Basically PHP does not do anything on such without GET/POST forms but with the help of JS in an particular event in the text box (like onKeyPress, KeyDown, onBlur, etc.) you can use the value entered in text box with other values.