I am looking to have a PDF calculate an answer based on the inputs from multiple fields and dropdowns.
I am using input fields for No. of Units, Oil Cost, Oil Changes per Week and a dropdown for Single Fryer which when all inputted will hopefully calculate a per annum cost for oil usage in a fryer.
The code I am trying to us is below;
I would expect with the below units inputted into their associated fields an answer of 62,400,
if ((this.getField("Single Fryer").value) = "MJ150") {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 25 * 52
} else if ((this.getField("Single Fryer").value) = "MJ140" {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 20 * 52
} else if ((this.getField("Single Fryer").value) = "SR42" {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 20 * 52
} else if ((this.getField("Single Fryer").value) = "RE114" {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 20 * 52
} else if ((this.getField("Single Fryer").value) = "RE117" {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 20 * 52
} else {
event.value = "N/A"
}
- No. of Units = 4
- Oil Cost ($/L) = 4
- Oil Changes per Week = 3
- Single Fryer = MJ150
However I am getting the below syntax error when trying to input the code;
SyntaxError: Missing ) after condition 3: at line 4
Am using Adobe Acrobat X if that makes a difference.
This is my first time using Javascript so any help/recommendations would be appreciated.
I am looking to have a PDF calculate an answer based on the inputs from multiple fields and dropdowns.
I am using input fields for No. of Units, Oil Cost, Oil Changes per Week and a dropdown for Single Fryer which when all inputted will hopefully calculate a per annum cost for oil usage in a fryer.
The code I am trying to us is below;
I would expect with the below units inputted into their associated fields an answer of 62,400,
if ((this.getField("Single Fryer").value) = "MJ150") {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 25 * 52
} else if ((this.getField("Single Fryer").value) = "MJ140" {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 20 * 52
} else if ((this.getField("Single Fryer").value) = "SR42" {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 20 * 52
} else if ((this.getField("Single Fryer").value) = "RE114" {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 20 * 52
} else if ((this.getField("Single Fryer").value) = "RE117" {
event.value = (this.getField("No. of Units").value) * (this.getField("Oil Cost").value) * (this.getField("Oil Changes per Week").value) * 20 * 52
} else {
event.value = "N/A"
}
- No. of Units = 4
- Oil Cost ($/L) = 4
- Oil Changes per Week = 3
- Single Fryer = MJ150
However I am getting the below syntax error when trying to input the code;
SyntaxError: Missing ) after condition 3: at line 4
Am using Adobe Acrobat X if that makes a difference.
This is my first time using Javascript so any help/recommendations would be appreciated.
Share Improve this question asked 13 hours ago SupOnlySupOnly 111 bronze badge New contributor SupOnly is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 5
===
or if that is somehow not supported then it should use==
:if ((this.getField("Single Fryer").value) === "MJ150")
– Peter B Commented 7 hours ago==
as shown in my working example. and if you reflow the logic will only be needed once for the 25 litre Drum. – K J Commented 6 hours ago