need help with javascript for form calculations
Copy link to clipboard
Copied
I use Adobe Acrobat to create pretty straight-forward fillable forms for my company often. However, I have a new order form I am creating and the only sticking point I have is trying to figure out how to get two different fields to do a calculation ONLY IF a specific button field is turned on.
I have the form totalling up the rows I need to get a NET TOTAL for all the pertaining rows, so I have that set. That is simple and will be the majority of the orders. But I also have a field just above that that is for 15% COMMISSION, then a GROSS TOTAL field is above that field. I only need the last two fields to populate if a certain button is clicked on the form. For this order form the majority of the time the orders are a simple NET total, so I have a button group at the top of the form... one is "NET" one is "GROSS". I have the "Net" button as the default. But if 15% commission needs to be subtracted from the gross total, the user is to click the "Gross" button. I need that action to put different totals in the fields. If the "Net" button at the top is clicked (as is the default) I ONLY want the total of rows to show in the NET TOTAL field, and the other 2 to stay blank.
How in the world do I get this to happen? I am not very well-versed in Javascript so I believe I need some custom scripts to make these actions. HELP!!! If you need some screen shots to get it better let me know.
Thanks in advance,
Wendy
Copy link to clipboard
Copied
Try the forum for Adobe Acrobat.
Copy link to clipboard
Copied
ok thanks. I thought I was in the right place... but I'll post there.
Copy link to clipboard
Copied
Try the forum for Adobe Acrobat.
Copy link to clipboard
Copied
For all of your calculated fields you need to use something like this as their custom calculation code:
if (this.getField("NetGross").valueAsString=="Net") {
// perform calculation for "Net" option
} else if (this.getField("NetGross").valueAsString=="Gross") {
// perform calculation for "Gross" option
} else {
// perform calculation for neither option, probably want to keep the field empty.
event.value = "";
]
Copy link to clipboard
Copied
Thanks for your response. So would I put those calculations in my totals fields? Do I have to do anything up at the buttons (one is "Gross" the other is "Net")?
Copy link to clipboard
Copied
Hi try67... I tried adding your JavaScript calculation code above into my form and it's giving me a Syntax error. See attached screenshot.
Copy link to clipboard
Copied
You have nothing after 'else{' you need to add script or remove else part if you don't need it.
Also, you don't have any calculation in your script, script from try67 was just an example, you need to add calculations where it says:
// perform calculation for "Net" option

