• New Commercial Services Section

    We have now opened a commercial services section here on the forum. If you have a Fabrik project that you wish to have someone work on for you, post it under Help Wanted. If you are an application developer and wish to earn some money helping others, post your details under Fabrik Application Developers.

    Both of these are unmoderated. It will be up to both parties to work out the details and come to an agreement.

Calculation

Folks

I have two fields where number values are added

1. rent_calculator___calc_1
2. rent_calculator___calc_srvc

I then have the calc element with the following code in

$v = '{rent_calculator___calc_1}' + '{rent_calculator___calc_srvc}' * 30; return sprintf("?%01.2f", $v);

What I want to do is to grab the two values, and multiply by 30

rent_calculator___calc_srvc will not always have a value entered

Example 1

Rent Per Month = 800
Service Charge = 60

Total ( x 30) = 25,800

Example 2

Rent Per Month = 800
Service Charge = 0

Total ( x 30) = 24,000

With the current setup the figures are not being returned properly

Can anyone provide me with the right guidance please?

Thanks
 
Hi Mark.
If you need to multiply the total by 30, your calc should read (you are missing the () ):

Code:
$v = ('{rent_calculator___calc_1}' + '{rent_calculator___calc_srvc}' )* 30; return sprintf("?%01.2f", $v);

Word of caution: the 'rent_calculator___calc_1' and 'rent_calculator___calc_srvc' can't be themselves calc elements because you are never sure in what order these calc get triggered.
 
Thanks Mark, I'm fine.

As far as I know, if you enable "ajax calculation" in the calc element, the value should change, not actually WHEN you type, but when you take the focus out of the field.
If you really need "sync", I guess you have to write your own Javascript to do so.
 
Good to hear :)

I thought as much - I'll take a look around and see what I can find

Thanks again :)

Regards

Mark


Sent via my iPhone using Tapatalk app
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top