Copy link to clipboard
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.
1 Correct answer
Use this:
var Value_a = getField("Value_a").value;
var Percent = getField("percent").value;
var Percentage = percent / 100;
event.value = Value_a * Percentage;
Copy link to clipboard
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
Copy link to clipboard
Copied
Use this:
var Value_a = getField("Value_a").value;
var Percent = getField("percent").value;
var Percentage = percent / 100;
event.value = Value_a * Percentage;
Copy link to clipboard
Copied
Thank you so much. This worked perfectly.
Copy link to clipboard
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.
Copy link to clipboard
Copied
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

