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

Javascript with minimum fee schedule- Please HELP!

New Here ,
Jun 02, 2016 Jun 02, 2016

Hello,  I am trying to figure out a JavaScript that will auto calculate the fee but will result a minimum fee.

Here is an example:

I have total project cost field (times) the .008 figured out, but will like to go a step further and when that number is below $50, then $50 appears in the last field. When the number is over $50, then the number shows. Example would be $10000 project will auto calculate and show $80.

Anybody know how to do a quick javascript for this scenario?

Thanks,

Patrick

TOPICS
Acrobat SDK and JavaScript , Windows
735
Translate
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 , Jun 02, 2016 Jun 02, 2016

Sure, it will be something like this (you might need to adjust the field names involved):

var result = Number(this.getField("total project cost").value) * 0.008;

event.value = Math.max(50, result);

Translate
Community Expert ,
Jun 02, 2016 Jun 02, 2016

Are you currently doing the calculation using JS? If so, post your code.

Basically it can be done like this (assuming the calculated value is stored in the "result" variable):

event.value = Math.max(50, result);

Translate
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 ,
Jun 02, 2016 Jun 02, 2016

Thanks for the reply,

I am not using JS currently, I have the fee automatically calculated by using the text table calculate feature in Adobe pro  but it seems I need a script to get what I am looking to do. Not sure if you can help guide me.

Patrick

Translate
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 ,
Jun 02, 2016 Jun 02, 2016

Sure, it will be something like this (you might need to adjust the field names involved):

var result = Number(this.getField("total project cost").value) * 0.008;

event.value = Math.max(50, result);

Translate
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 ,
Jun 03, 2016 Jun 03, 2016

Thanks a lot, The minimum fee works great. Would it be an easy way to create a max fee of $185,000.00?

Translate
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 ,
Jun 03, 2016 Jun 03, 2016

Sure:

var result = Number(this.getField("total project cost").value) * 0.008;

event.value = Math.min(Math.max(50, result), 185000);

Translate
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 ,
Jun 03, 2016 Jun 03, 2016

It works.....

Thanks so much! Have a great weekend!!!

Translate
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 ,
Jun 21, 2016 Jun 21, 2016

Try67

Is there a way to have the balance show zero if nothing is entered in the above lines? The min fee and the highest fee work great, but we like to show $0.00 if no one enters a number and just prints the form off. Right now if you just print the form off the min. fee shows up and may not be the case if someone prints it off and fills it by hand...

Thanks for any help!

Translate
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 ,
Jun 21, 2016 Jun 21, 2016
LATEST

Change it to this:

var result = Number(this.getField("total project cost").value) * 0.008;

if (result==0) event.value = "";

else event.value = Math.min(Math.max(50, result), 185000);

Translate
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