Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Java Script for calculation in DC

New Here ,
Nov 13, 2017 Nov 13, 2017

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.

TOPICS
Acrobat SDK and JavaScript , Windows
480
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 14, 2017 Nov 14, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2017 Nov 14, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 14, 2017 Nov 14, 2017

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2017 Nov 14, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2017 Nov 16, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines