Java Script for calculation in DC

New Here ,
Nov 13, 2017

Copy link to clipboard

Copied

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

Views

231

Likes

Translate

Translate

Report

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

Java Script for calculation in DC

New Here ,
Nov 13, 2017

Copy link to clipboard

Copied

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

Views

232

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 13, 2017 0
Most Valuable Participant ,
Nov 14, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 14, 2017 0
Most Valuable Participant ,
Nov 14, 2017

Copy link to clipboard

Copied

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;

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 14, 2017 0
try67 LATEST
Most Valuable Participant ,
Nov 16, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 16, 2017 0