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

Fillable Form - Calculations using Exponents

New Here ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Please help. I have run into a stumbling block, the use of exponents or raise to the power of operation inside fillable forms.  I'm using Adobe Acrobat DC Pro. As an example,  2^3 returns an answer of 1 vs. 8.  I have also attempted to use "**" and "Math.pow" without any luck. Does anyone know how to correct/fix/modify so that I can complete my form.  This is my last hurdle and a required one.   Thank you for your help!

TOPICS
How to , JavaScript , PDF forms

Views

1.7K

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
community guidelines

correct answers 3 Correct answers

Community Expert , May 27, 2021 May 27, 2021

try Math.pow(2,3)

Votes

Translate

Translate
Community Expert , May 27, 2021 May 27, 2021

Please post the exact code you are using.  You know, Simplified Notation and JavaScript are completely different. They are not interchangable in any way. 

 

Did you try out the test code I suggested?  

 

Here's an article on performing simple calculations:

https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations/

 

 

Votes

Translate

Translate
Community Expert , May 27, 2021 May 27, 2021

In your script you forgot to add '.value' to "Months" field.

Votes

Translate

Translate
Community Expert ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

try Math.pow(2,3)

Votes

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
community guidelines
Community Expert ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Math.pow() is the correct function

 

var x = Math.pow(2,3);

 

Returns 8. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
New Here ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Please no more emails 

Votes

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
community guidelines
New Here ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Hi Everyone.  Thank you for the responses.  However, when I try using Math.pow(x,x) the formula is not working.  Following is the behind the scenes.  I'm sure it's a simple mistake but...

Amy5C20_0-1622139762858.png

 

Votes

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
community guidelines
Community Expert ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

You are using JavaScript in the "Simplified Notation" area. JavaScript can only be entered into the "Custom Script Calculation" area.

 

start out with 

 

event.value = Math.pow(2,3);

 

You can read more about form scripting here:

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
New Here ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Please note, I have tried placing the formula in both the Simplified and Custom calculation fields.  No luck!

Votes

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
community guidelines
Community Expert ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Please post the exact code you are using.  You know, Simplified Notation and JavaScript are completely different. They are not interchangable in any way. 

 

Did you try out the test code I suggested?  

 

Here's an article on performing simple calculations:

https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations/

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
New Here ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Thom,

Yes, I tried the exact code you suggested to no avail.  Thank you for the articles.  I just tried the following: 

event.value = Math.pow(this.getField("Payment_S2").value,this.getField("Months"));

The result was NaN. 

 

Ultimately, I am trying to get a monthly payment amount for a lease agreement. Based upon the nomenclature in my form, the full formula (not JavaScript) should look like:

((Net_Financed*(Monthly_IR))*((1+(Monthly_IR))^Months))/((1+(Monthly_IR))^Months-1)

The formula breaks down when a value needs to be raised to the power of x, in this case # of months.

 

 

 

Votes

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
community guidelines
Community Expert ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

In your script you forgot to add '.value' to "Months" field.

Votes

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
community guidelines
New Here ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

LATEST

You're brilliant!  It works!  Thank you for perservering with me.  

Votes

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
community guidelines
LEGEND ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Your screen shot is too small to read, unfortunately. But you need to not just show us the code, but also tell us what you WANT to happen and what ACTUALLY happens. If you look at your code, we may be able to know what it will do, but we certainly can't guess what you are wanting if it's something different...

Votes

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
community guidelines