Skip to main content
Participant
May 8, 2018
Question

Excel to Javascript Formula Help

  • May 8, 2018
  • 1 reply
  • 394 views

I'm creating an Adobe Acrobat Pro DC form using an excel spreadsheet as a template.  My excel formula is IF(Productivity=0,,Total/Productivity*8)

I can't get the "if else" formula to work in Javascript.

This topic has been closed for replies.

1 reply

Inspiring
May 9, 2018

Literraly, it would be:

if (Productivity == 0) event.value = ""

else event.value = Total / Productivity * 8

and you would copy this script in the calculate tab of the field you want the calculation to take place.  This is all providing that you assigned a value to the variables named Total and Productivity.

So functionally, since an evaluation of your "if statement" to TRUE doesn't do anything, you should only evaluate the FALSE eventuallity:

if (Productivity != 0) event.value = Total / Productivity * 8

There is no need for an "else statement".  The complete code would be this:

var Total = this.getField("Name the field where that value is found").value

var Productivity = this.getField("Name the field where that value is found").value

if (Productivity != 0) event.value =Total / Productivity * 8

If it is not clear, come back with the name of your fields.