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

I am attempting to develop a pdf form that will perform calculations based on user input. I have been able to accomplish some of the more basic calculations, such as multiplication, but am having trouble when it comes to performing some of the more comple

New Here ,
Nov 29, 2017 Nov 29, 2017

Copy link to clipboard

Copied

I have attempted to break my equation down and only perform the power or square root functions and the text box does not respond. So i have narrowed it down to the fact that neither of these math functions are working for me.

Views

813

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 1 Correct answer

LEGEND , Nov 30, 2017 Nov 30, 2017

The custom calculation script for the field could be something like:

// Custom calculation script for text field

(function () {

    // Get the field values, as numbers

    var v1 = +getField("UserEntry1").value;

    var v2 = +getField("UserEntry2").value;

    var v3 = +getField("UserEntry3").value;

    // Perform the calculation and set this field's value

    event.value = 29.84 * v1 * Math.sqrt(v2) * Math.pow(v3, 2);

{)();

When troubleshooting JavaScript, it is helpful to check the JavaScript console (Ct

...

Votes

Translate

Translate
New Here ,
Nov 29, 2017 Nov 29, 2017

Copy link to clipboard

Copied

I believe my problem statement was cut off. Here is it: I am attempting to develop a pdf form that will perform calculations based on user input. I have been able to accomplish some of the more basic calculations, such as multiplications, but am having trouble when it comes to performing some of the more complex calculations. I am attempting to perform the following calculation (29.84*UserEntry1*sqrt(UserEntry2)*(UserEntry3^2). I have read several forums and I understand that adobe pro uses JavaScript, so I have attempted to incorporate commands such as Math.pow("UserEntry3",2). I have also tried Math.pow(this.getField("UserEntry3").value*1,2). In a similar fashion I have attempted to use the Math.sqrt function with no luck. I do not receive an error with my equation. The box simply is unresponsive to any user input values. Any ideas as to what could be the issue?

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 ,
Nov 30, 2017 Nov 30, 2017

Copy link to clipboard

Copied

The custom calculation script for the field could be something like:

// Custom calculation script for text field

(function () {

    // Get the field values, as numbers

    var v1 = +getField("UserEntry1").value;

    var v2 = +getField("UserEntry2").value;

    var v3 = +getField("UserEntry3").value;

    // Perform the calculation and set this field's value

    event.value = 29.84 * v1 * Math.sqrt(v2) * Math.pow(v3, 2);

{)();

When troubleshooting JavaScript, it is helpful to check the JavaScript console (Ctrl+J) for errors.

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 ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

Thank you! That worked great! so if i would want to follow up with the following calculation: AutoCalc1*((UserEntry2 - 20)/(UserEntry2 - UserEntry3))^0.54).

Shouldn't the following script work:

var v1 = +getField("AutoCalc1").value;

var v2 = +getField("UserEntry2").value;

var v3 = +getField("UserEntry3").value;

event.value = v1 * Math.pow(((v2 - 20)/(v2 - v3)), 0.54);

I am being prompted with a  window that says the value entered does not match the format of the field. Don't quite understand the issue.

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 ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

You need to make sure that the result of v2-v3 is not zero, as that would mean division by zero, which is not allowed.

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 ,
Dec 03, 2017 Dec 03, 2017

Copy link to clipboard

Copied

LATEST

Change the format of the field to "None" and observe what appears. It could be "NaN", a number expressed in scientific notation, "Infinity", or "-Infinity". You can then adjust your script to handle the result in an appropriate manner. 

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