Adding a checkbox for rush order calculation
Hello!
I am very new to javascript. I am using Acrobat DC Pro. I have successfully set up an order form that tallies up check boxes for each type of sample that is sent in (for a genetic test on animals s*m*n/colostrum/saliva), and collects total number of each type, and also successfully got the order for to total a sum of each checkbox and multiplied them with the cost. This worked fine!
Here comes the challenge (for me at least)! I was then tasked with adding an optional rush order option via a checkbox. This changes the amount from 35$ a test to 50$ a test. I am having a hard time figuring out how to accomplish this. Each time I try, it either keeps the amount of 50$ from when the checkbox was checked and does not remove that calculations if the checkbox is then unchecked (say they changed their mind after seeing how much it would be etc). OR The checkbox comes unchecked on its own (weird) and none of the calculations work at all, but it still appropriately tallies up the boxes without cost.
I have the following code in the field where total cost is calculated. Is that correct? should I have something going on in the RushOrder checkbox field other than its value when clicked equaling Yes? What am I missing? What have I done wrong, etc? Any help would be appreciated!
This is the code I am using:
// Get field value, as a number from each type
var v1 = +getField("SemenSum1").value;
var v2 = +getField("SalivaSum1").value;
var v3 = +getField("ColostrumSum1").value;
//Checkbox rush order value
var RO = this.getField("RushOrder").value;
// Calculate and set this field's value to the result
if(getField("RO").value!="Yes"){
event.value = 50*(v1 + v2 + v3);}
else{event.value = 35*(v1 + v2 + v3);}
