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

Multiplying a form field by a specific number.

New Here ,
Jan 08, 2019 Jan 08, 2019

Copy link to clipboard

Copied

How do I multiply a numerical form field by a specific number that is not in a form field?  I have absolutely no experience with Javascript.  Please HELP!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

12.8K

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

Community Expert , Jan 08, 2019 Jan 08, 2019

Let's say the first field is called Text1 and you want to multiply its value by 8 and show the result in Text2.

You can do it using this code as the custom calculation script of Text2:

event.value = Number(this.getField("Text1").valueAsString) * 8;

Also, see this tutorial: https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

Votes

Translate

Translate
Community Expert ,
Jan 08, 2019 Jan 08, 2019

Copy link to clipboard

Copied

Let's say the first field is called Text1 and you want to multiply its value by 8 and show the result in Text2.

You can do it using this code as the custom calculation script of Text2:

event.value = Number(this.getField("Text1").valueAsString) * 8;

Also, see this tutorial: https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

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 ,
Jan 08, 2019 Jan 08, 2019

Copy link to clipboard

Copied

THANK YOU THANK YOU THANK YOU!  I appreciate it so much.

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 Beginner ,
Mar 02, 2024 Mar 02, 2024

Copy link to clipboard

Copied

Great answer! Thanks. If you're willing to add more, I was needing to know:

What additional script would I need if I want Text2 to be left blank and ONLY want something to show in Text2 if Text1 has input?

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 ,
Mar 02, 2024 Mar 02, 2024

Copy link to clipboard

Copied

Use this:

if(this.getField("Text1").valueAsString === "")
event.value = "";
else
event.value = Number(this.getField("Text1").valueAsString) * 8;

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 Beginner ,
Mar 03, 2024 Mar 03, 2024

Copy link to clipboard

Copied

LATEST

Perfect! Thank you so much!!

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