5 Replies Latest reply on Nov 16, 2017 5:27 AM by try67

Java Script for calculation in DC

Hi,

I have zero experience with Java script and only just figured out calculations in Livecycle before they shut down support & now our forms won't open - i've had to re-crate our forms in Adobe DC.

I need to write a calculation, I have 3 number fields (Quantity, Price, Total)

Item               Quantity                                                                 Price          Total

Battery          less that 35 batteries                                               \$25             \$25

Battery          more than 35 batteries, less than 69 batteries        \$25             \$50

Battery          more than 70 batteries, less than 104                     \$25              \$75

OR in other words, for every 5kg of batteries (which we worked out to be approx 35 batteries) ordered there is a \$25 charge (per 5kg) added to the total. So if they order 35 batteries = 5kg = \$25, if they order 40 batteries it would be \$50 as we'd have to round up to 10kg.

Does anyone know how I write this in Java Script to enter into 'simplified field notification' or 'custom calculation script'

SO MUCH THANKS if anyone can help!

Amanda

edit: I'm using Adobe DC, i've got a form I made previously in livecycle that I'm converting the fields to fillable fields in Adobe DC.

• 1. Re: Java Script for calculation in DC

LiveCycle Designer is still sold and supported but no longer  bundled with Acrobat.

• 2. Re: Java Script for calculation in DC

As the custom calculation script of the Total field enter:

```var qty = Number(this.getField("Quantity").value);
var price = Number(this.getField("Price").value);
event.value = Math.ceil(qty/35)*price;
```
• 3. Re: Java Script for calculation in DC

we have been having issues for a long time with people being able to open our livecycle created forms in adobe - we contacted adobe and they said it's no longer supported, and advised us to use adobe DC to create forms.

Which sucks because all our forms have been created in livecycle and i can't edit them straight through adobe DC create form/edit. I need to save it as a plain pdf and then add the form sections over the top of the fields previously used

• 4. Re: Java Script for calculation in DC

Thanks try67 - i plugged that in and changed "Quantity" to be the cell name (ie Text6.0.0) & same for Price - but it didn't work. Is there something else I needed to change - It came up as NaN in the box

• 5. Re: Java Script for calculation in DC

That means that value of one of your fields is not a pure number, but contains non-digit characters.