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

Need script to calculate a percentage of a dollar figure

Community Beginner ,
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

691

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 , 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;

Votes

Translate

Translate
Community Expert ,
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 ="";

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 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;

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

Thank you for spotting that NesaNurani.

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 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.

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 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.

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 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.

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