Calculated Field on fly

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Fakiro82
User
Posts: 108

Calculated Field on fly

Post by Fakiro82 »

Hi,
I have two field (Price and Quantity).
I need two calculated on fly field "Total".
My code in Row_Updating is:

// Row Updating event
function Row_Inserting($rsold, &$rsnew) {
// Enter your code here
// To cancel, set return value to FALSE 
$rsnew["Total"] = $rsnew["Price"] * $rsnew["Quantity"]; 
return TRUE;
}

only after clicking on save I see the total field updated. I would like to see the update right away, as soon as I enter the new values.
Is it possible? Can i do this?

Thank you,
Andrea.


sangnandar
User
Posts: 980

Post by sangnandar »

You can find the exact example on project demo table orders/orderdetails.
Check Edit Tag --> Client side events of the related fields.


Fakiro82
User
Posts: 108

Post by Fakiro82 »

Hi sangnandar,
the example is ok but I need to do this on database field "Total" and not on custom field.
Any idea?

Thank you,
Andrea.


sangnandar
User
Posts: 980

Post by sangnandar »

They'll behave the same.
Give it a try.

But I would recommend not to keep "Total" as db field since it caused redundancy (same data stored twice). To get ease of immediate result you can use db virtual/computed column (if you're using MySQL/MariaDB).


Fakiro82
User
Posts: 108

Post by Fakiro82 »

Hi sangnandar,
it's work.

Thank you so much,
Andrea.


Post Reply