Simple form - calculate A * B = C and save to database

This has got to be simple. I have a simple form with 3 decimal fields. I want to calculate {C} = {A} * {B} … and save the value of C in my table. I have an ajax event that correctly does the calculation when the value of B changes. I can see it on screen. I copied my calculation to onBeforeInsert & onBeforeUpdate.

When I insert a new record, it does not save the value of C to my table. If I retrieve the record and choose SAVE (ie. update the record) it saves the value.

I have tried putting the calculation in onValidateSuccess.

It does not save the value of C to the database after inserting a record.

Solved. One of my fields (B) was a select from another table - and thus did not exist until the record was saved - so had a value of zero. What I did to fix it was use sc_lookup in OnValidateSuccess to do a 2nd lookup to that field.