Highlighted

Custom Calculation Script

New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

I wrote out a formula in Excel and then tried to convert it to an Adobe form...

In Excel...

Adobe1.jpg

 

For the Custom Calculation Script

I set up the 5 fields as A, B, C, D, E,

For the equation i wrote...

event.value = ((getField("C").value - getField("A").value ) / 600) / ((getField("D").value * 0.037) / (2 ^ (getField("E").value / 271)))

Any help in getting this on track would be greatly appreciated.

TOPICS
PDF forms

Views

67

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

Custom Calculation Script

New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

I wrote out a formula in Excel and then tried to convert it to an Adobe form...

In Excel...

Adobe1.jpg

 

For the Custom Calculation Script

I set up the 5 fields as A, B, C, D, E,

For the equation i wrote...

event.value = ((getField("C").value - getField("A").value ) / 600) / ((getField("D").value * 0.037) / (2 ^ (getField("E").value / 271)))

Any help in getting this on track would be greatly appreciated.

TOPICS
PDF forms

Views

68

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 02, 2020 0
Contributor ,
Nov 02, 2020

Copy link to clipboard

Copied

What do you have trouble with?

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 02, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

I am getting a result of 00 so i assume something is wrong with the script.

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 02, 2020 0
Adobe Community Professional ,
Nov 02, 2020

Copy link to clipboard

Copied

Were any errors reported in the Console Window?

You'll find a tutorial on using the Console here: https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

It may help if the calculation is broken into separate lines of code, where you can ensure each part is done correctly.

 

Please explain the exact problem. 

 

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 02, 2020 1
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

I am not seeing any errors when i write the script, select ok in the editor or when i close the test field properties.

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 02, 2020 0
Adobe Community Professional ,
Nov 02, 2020

Copy link to clipboard

Copied

May be a problem with ^

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 02, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

I was wondering if that might be the cause.  I tried ** but that generated errors....

I Just found another operator, Math.pow() and that works...so the formula is  now   

 

event.value = ((getField("C").value - getField("A").value ) / 600) / ((getField("D").value * 0.037) / (Math.pow(2, (getField("E").value / 271))));

 

Thank you all so much for the help!!

The best to all and be well...

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 02, 2020 0
Most Valuable Participant ,
Nov 02, 2020

Copy link to clipboard

Copied

In addition you should account for the situation where there's a division by zero (because field "D" is empty, for example), which will result in an error message if you've set the calculated field to have the Number format.

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 02, 2020 0
New Here ,
Nov 03, 2020

Copy link to clipboard

Copied

Yes, I did notice that error message. Since I have ZERO JavaScript skills I prefilled the boxes with 1. In my form the User will need to enter numbers in each box so the 1 will get overwritten; prefilling the box with a 1 did stop the error message.

It seems there should be something I could have done in that equation to prevent the divide by zero, but I was not sure how to do that. Do you have any recommendations??

Can you recommend a good book for getting started in JavaScript???

Sent from Mail for Windows 10

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 03, 2020 0
Adobe Community Professional ,
Nov 03, 2020

Copy link to clipboard

Copied

JavaScript is really two different things, the Core Language and the Document Object Model. The Core Language is the same everywhere, but the DOM is specific to the application. So you have to be careful when reading about JavaScript. Most material will be about HTML scripting, which has a totally different DOM than Acrobat. 

The best book is the O'Reilly "JavaScript, the Definitive Guide" because it has a clear separation between Core JS (about 40% of the book) and the HTML DOM. 

The best source for info on the Acrobat specific DOM is www.pdfscripting.com

Watch the free videos here:

https://www.pdfscripting.com/public/Free_Videos.cfm

 

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 03, 2020 0
hlandor LATEST
New Here ,
Nov 03, 2020

Copy link to clipboard

Copied

Thanks!!

I appreciate the information!!

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 03, 2020 0