5 Replies Latest reply on Sep 23, 2014 6:07 AM by try67

# Converting excel formulas to javascripts

Hello, I am not experience in Excel formulas and creating "if" statements in Adobe Acrobat, so I'm hoping someone can help me with this. I have two problems.

1.  Here is an excel formula that I need to convert over to javascripts. Can someone help with this?

=IF(Q13>0,Q13+0,"")

2.  Here is the second one,

=IF(N16*Q16>0,((N16*Q16)+U16),"")

In addition to these two formulas I need help with, the owner of the forms does not want the numbers to round up. Is there a way to get the exact answer and not rounding the numbers up in javascript?

• ###### 1. Re: Converting excel formulas to javascripts

Have you looked at any of the tutorials on the Adobe site form Acrobat forms?

• ###### 2. Re: Converting excel formulas to javascripts

No, I have not looked there. I was hoping someone might  be able to show me the codes to use.

• ###### 3. Re: Converting excel formulas to javascripts

For #1, the custom calculation script could be:

var Q13 = +getField("Q13").value;

event.value = Q13 > 0 ? Q13, "";

For #2, it could be:

var N16 = +getField("N16").value;

var Q16 = +getField("Q16").value;

var U16 = +getField("U16").value;

event.value = N16 * Q16 > 0 ? N16 * Q16 + U16 : "";

This assumes your field names are N16, Q16, etc., so if they're different, use the actual field names with the getField method.

• ###### 4. Re: Converting excel formulas to javascripts

Hi George, on the first script

var Q13 = +getField("Q13").value;

event.value = Q13 > 0 ? Q13, "";

It comes up with a SyntaxError: missing : in conditional express 2: at line 3

Do you know what that means and how to correct?

Thanks

Connie

• ###### 5. Re: Converting excel formulas to javascripts

Change the last line to:

event.value = Q13 > 0 ? Q13 : "";