3 Replies Latest reply on May 22, 2014 6:38 AM by Rvdlee

# Using lineair formula, but outcome 0 if X=0

Hi all,

I am new to this forum and working with Adobe Acrobat X pro for some months now. Currently I am facing some difficulties with a formula. Simplified, I want Adobe to calculate the price of a hose, with fixed costst (couplings) and variable costs (length of the hose, based on the numbers of meters that they select). Their response can be chosen in a dropdown menu in meters (0, 5, 10, 15, 20, 25). The calculation that follows is simple:

451 + 8X

However, since the item is an option, if X= 0 this means that the user does not want the item at all. Yet the result still equals 451 euros. I want the outcome to be 0 if 0 meters is selected.

In excel we could solve the issue using the Round function (Round equals 1 if X > 0 and 0 if X equals 0. However, in PDF I have no clue how to deal with this (javascript I guess?).

In practice it is slightly more complicated, since the same hose can be selected for 2 separate purposes and I want to show the total of these two as outcome. That is, the formula is 451*(1(if hose is wanted for a) + 1(if hose is wanted for b))  + 8(a+b) . See screenshot for what I mean.

Can you help me?

• ###### 1. Re: Using lineair formula, but outcome 0 if X=0

Hi all again,

Could anyone perhaps help me with the question I posted earlier?

In case I explained it unclear, please let me know!

• ###### 2. Re: Using lineair formula, but outcome 0 if X=0

You have to use custom calculation scripts to perform the calculations. You need to use the conditional statement i

f(logical test) {

//block of script

} else {

//block of script

}

to perform conditional execution of blocks of code.

Custom scripts require a lot of details and a very clear statement of the problem.

• ###### 3. Re: Using lineair formula, but outcome 0 if X=0

Hi GKaiseril,

I am very unfamiliar with the usage of javascript. Could you perhaps be more specific in the code that I have to use?

If neccessary I can give you a more detailed problem description?

Thanks!

Rene