Copy link to clipboard
Copied
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
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);
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Thanks a lot, The minimum fee works great. Would it be an easy way to create a max fee of $185,000.00?
Copy link to clipboard
Copied
Sure:
var result = Number(this.getField("total project cost").value) * 0.008;
event.value = Math.min(Math.max(50, result), 185000);
Copy link to clipboard
Copied
It works.....
Thanks so much! Have a great weekend!!!
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now