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!
try Math.pow(2,3)
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/
In your script you forgot to add '.value' to "Months" field.
Copy link to clipboard
Copied
try Math.pow(2,3)
Copy link to clipboard
Copied
Math.pow() is the correct function
var x = Math.pow(2,3);
Returns 8.
Copy link to clipboard
Copied
Please no more emails
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...
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
Copy link to clipboard
Copied
Please note, I have tried placing the formula in both the Simplified and Custom calculation fields. No luck!
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/
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.
Copy link to clipboard
Copied
In your script you forgot to add '.value' to "Months" field.
Copy link to clipboard
Copied
You're brilliant! It works! Thank you for perservering with me.
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...