• Global community
• Language:
• Deutsch
• English
• EspaÃ±ol
• FranÃ§ais
• PortuguÃªs
• æ—¥æœ¬èªžã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£
Dedicated community for Japanese speakers
• í•œêµ­ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Exit

New Here ,
May 11, 2018 May 11, 2018

Copied

I need to have an adobe acrobat form calculate a percentage. I have a field named, value_a that I need to multiply by a user entered value. For example is value_a is 100 and the user enters 20 in the percent field, I would like the form to calculate that 20% of 100 is 20. I don't know java script but this seems like it would be easy but I can't figure it out.

TOPICS
Acrobat SDK and JavaScript

Views

5.6K

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 Expert , May 12, 2018 May 12, 2018

Use this:

var Value_a = getField("Value_a").value;

var Percent = getField("percent").value;

var Percentage = percent / 100;

event.value = Value_a * Percentage;

5 Replies 5
New Here ,
May 11, 2018 May 11, 2018

Copied

var Value_a = getField("Value_a").value;

var Percent = getField("percent").value;

var Percentage = (percent / 100).value;

event.value = Value_a x Percentage;

This is what I am trying to do. The Percentage variable is not a field in my form. I am trying to get it to calcluate the percentage value because the user will enter 5 for 5% off. It give me this error: missing ; before statement 4: at line 5

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 Expert ,
May 12, 2018 May 12, 2018

Copied

Use this:

var Value_a = getField("Value_a").value;

var Percent = getField("percent").value;

var Percentage = percent / 100;

event.value = Value_a * Percentage;

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 12, 2018 May 12, 2018

Copied

Thank you so much. This worked perfectly.

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 12, 2018 May 12, 2018

Copied

It is best to use the "Percentage" format and then enter the decimal value. This will allow other calculations to directly used the stored value in the field in additional calculations without any type of conversion. Note that the "Format" option only changes the visually displayed value of the field and not the contents or actual value of the field. If you want to allow users to enter a whole number for the percentage, then use JavaScript to pop-up an app.response dialog to enter the whole number value and then compute the decimal value to be entered into the field.

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 Beginner ,
Mar 11, 2021 Mar 11, 2021

Copied

LATEST

Please can you help me with something similar?

I need to set a calculation so that when a person enters a number into the '5PercentageUplift' box it will add this to the '5OwnStockSubTotal' and give me the total '5TotalsPercentageOwnStock'.

Do I set the '5PercentageUplift' box to number or percentage?

Many thanks