Making a number negative based on a drop down

Making a number negative based on a drop down

Hi,

Finally I have time to explore Zoho Creator. I am beginning by making an expense tracker, based on something like SplashID.

In the date entry form I want to have a drop down menu named Direction, with two options: money in and money out.

Below is a field called Amount into which I will type the amount I spent or received. I want to be able to type a simple (positive) number there.

On submission, if the Direction field contains "Money Out" then I want the contents of the Amount field to be saved in the database as a negative number.

(If I spend 10� then I want to enter 10.00� in the Amount field, mark it as "Money Out", then have it saved in the database as -10.00.

I have spent a couple of hours trying to find a way of scripting this, but have not got it working yet.

My last attempt (on Edit -> on Success) looked like this:

if (input.Direction == "Money Out")
{
moneySpent = (input.Amount - input.Amount * 2);
input.Amount = moneySpent;
}

What am I doing wrong?

Cheers
Owen