This topic is locked

fields from query

11/12/2008 1:25:06 PM
PHPRunner General questions
S
szjunior author

Help me please !!
I have 2 fields in Visual Editor:
Quantity --> normal input by keyboard
Value ---> populate by dependent dropdown
Im using the following to do a calculation in BeforeAdd event to put the result in the total field.
$var1 = $values["quantity"] ;
$var2 = $values["value"] ;
$sum = $var1 * $var2 ;
whats wrong ? , because only the content of the normal input works . The value populate by the dependent does not work.
Is there another action to do ?
I´ve tried to do a query with the sum but my problem is how to fill the database field with the value generated by the query ?
thanks

S
swanside 11/12/2008

Can you not do it SQL? like Quantity*Value=Sum and save it that way?

S
szjunior author 11/12/2008

Ok, it work, but when I save the form, the field that contains the calculation does not save, the other fields save normaly.
see the picture. after edit form the value was filled.
How to solve that ? what´s wrong ??.. I need to fill the fields with this SQL in the first moment ... ADD form.


Can you not do it SQL? like Quantity*Value=Sum and save it that way?

J
Jane 11/13/2008

Hi,
you need to add calculated result to the $values array:

$var1 = $values["quantity"] ;

$var2 = $values["value"] ;

$sum = $var1 * $var2 ;

$values["Total"] = $sum;