## Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.

• Fillable Form - Calculations using Exponents

# Fillable Form - Calculations using Exponents

New Here ,
May 27, 2021 May 27, 2021

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

734

Likes

Report

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

Adobe Community Professional , May 27, 2021 May 27, 2021
try Math.pow(2,3)

Likes

Adobe Community Professional , 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/

Likes

Adobe Community Professional , May 27, 2021 May 27, 2021

Likes

11 Replies 11
May 27, 2021 May 27, 2021

Copied

try Math.pow(2,3)

Likes

Report

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

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
May 27, 2021 May 27, 2021

Copied

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
May 27, 2021 May 27, 2021

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...

Likes

Report

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

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);

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

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
May 27, 2021 May 27, 2021

Copied

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

Likes

Report

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

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
May 27, 2021 May 27, 2021

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.

Likes

Report

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

Copied

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
May 27, 2021 May 27, 2021

Copied

LATEST

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

Likes

Report

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

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...

Likes

Report

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