Copy link to clipboard
Copied
I have a Java script to make a calculation a percentage:
if (event.value) event.value+="%"
it works great but how to I fix it so it only will calculate to 2 decimal points? And where do I add it ?
I am a total rookie at this.
Copy link to clipboard
Copied
When you post a question you always need to tell the program you are using
There are MANY programs in a full subscription, plus other non-subscription programs
Please post the exact name of the Adobe program you use so a Moderator may move this message to that forum
Copy link to clipboard
Copied
@John T Smith is spot on with the information that you need to supply for someone to help you accurately. However, if it's JS that you are using something like the following could work
if (event.value) event.value = parseFloat(event.value).toPrecision(3) + "%"
-Manan
Copy link to clipboard
Copied
I am using adobe acrobat pro on a MacBook
Copy link to clipboard
Copied
Holy guacamole! Thank you it worked !! Yay!!!
Copy link to clipboard
Copied
Manan had the correct fix
Copy link to clipboard
Copied
There is no need for script, in field properties, select 'Format' tab then select percentage and select number of decimals.
Copy link to clipboard
Copied
The problem with doing it like that is that it doesn't actually change the field's value, so if you use it later on in another calculation you might get unexpected results.
Copy link to clipboard
Copied
Although, the other solution given above has the same issue, of course... You must not use the Format event if you want to avoid this problem.
Copy link to clipboard
Copied
I tried solving the problem in the format field before reaching out to the forum but it didn't work. The script from Manan Joshi worked perfectly!