This topic is locked

post negative value on a field based on other field value

8/10/2018 8:45:50 AM
PHPRunner General questions
A
andreasc author

I have a dropdown with two options [income]&[Expense] and a field [amount].

what I want is if I select [Expense] to post negative value at [amount]
Thanks

HJB 8/10/2018

Custom format via "View as" settings in Visual Editor
quote
global $data;

if ($data["amount"]=="Expense")

$value = $value * (-1);

A
andreasc author 8/10/2018



Custom format via "View as" settings in Visual Editor
quote
global $data;

if ($data["amount"]=="Expense")

$value = $value * (-1);


Thanks for your reply
I apologize for not correctly explaining my problem.
I have 2 fields 1.type 2.amount
forget to say that [Income]&[Expense] are options of [type] field

so if Expense option is selected on [type] field then value of [amount] field must post as negative value
Thanks

HJB 8/10/2018



Thanks for your reply
I apologize for not correctly explaining my problem.
I have 2 fields 1.type 2.amount
forget to say that [Income]&[Expense] are options of [type] field

so if Expense option is selected on [type] field then value of [amount] field must post as negative value
Thanks


... it is my commercial understanding that we have only ONE field to appear NEGATIVE, namely AMOUNT once EXPENSE is selected.

A
andreasc author 8/10/2018

no there are 2 fields
field1 = type

field2 = amount
type options = Income and Expense

if type is Expense then must post amount negative