Need script to calculate a percentage of a dollar figure

New Here ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Is there a way or script to type a dollar amount into a field and have that same field show 15% of the dollar figure entered?

In other words, if I type $1,000 into the field  I want it to calculate 15% of $1,000 and show $150.

Any help would be appreciated. Thank you.

TOPICS
How to, JavaScript, PDF forms

Views

212

Likes

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

Adobe Community Professional , Mar 25, 2021 Mar 25, 2021
That code would work but it will keep calculating *.15 every time there is change in form. Try using this as "Validation" script: event.value = event.value*.15;

Likes

Translate

Translate
Adobe Community Professional ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Yes, you can try something like this:

 

Open the "Prepare Form" tool, right-click on that textfield and select "Properties" from the context menu.

 

You may go to the "Format" tab and in the "Select format category" dropdown menu choose "Number".

 

Below that, in the Number Options section select 0 for decimal places and $ for the currency symbol.

 

Then go to the calculate tab and tick the radio button "Custom Calculation Script", then click on the "Edit" button.

 

You may use a script like this:

 

if (event.value > 0) {

 

event.value = event.target.value * .15;

 

}

 

else event.value ="";

Likes

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
Adobe Community Professional ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

That code would work but it will keep calculating *.15 every time there is change in form.
Try using this as "Validation" script:
event.value = event.value*.15;

Likes

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 ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Thank you so much! So far in testing, this has worked the best.

Likes

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
Adobe Community Professional ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Thank you for spotting that NesaNurani.

Likes

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 ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

I just wanted to thank you for trying to help. While Nesa's script provided the answer, your input was greatly appreciated.

Likes

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 ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

The last post "I just wanted to thank you for trying to help. While Nesa's script provided the answer, your input was greatly appreciated." was intended for Is_rbls. I think I posted to the wrong reply. Your help was also appreciated.

Likes

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
Adobe Community Professional ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

LATEST

You're welcome, and no worries we're all here to help in one way or the other.

Likes

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