Copy link to clipboard
Copied
Attached is a simple calculator with a formula for savings and product volume.
I would like to know how to use javascript to calculate off the text box input and off variables in the background as seen in the sheet. Ideally in the PDF- it would be spend text box 1 (b3), volume text box 2 (b5) and then the final result text box (b11-13). Just would like some guidance based off the excel formula and thanks!
Copy link to clipboard
Copied
You can create hidden fields and set the default values to fields you don't want to show (Variable, Monthly Spend, Annual Spend) but it is not necessary if 1.65 is not going to change. You can write the entire calculation in the Total Savings field. Assume you have to fields named "Spend" (formatted as a 2-decimal number) and "Volume" (formatted as a percentage - both names are case sensitive). Here's the custom calculation script that would go in the Total Savings field:
var spend=this.getField("Spend").value;
var volume=this.getField("Volume").value;
event.value=((spend/1.65)*12*volume*0.085)+(spend*(1-volume))*.05;
Copy link to clipboard
Copied
- Wrong post, sorry -