Custom Calculation Script in forms - Help
I have a bit of a complex calculation needed so any help would be greatly appreciated! Screen shots of what I am working on is included, along with a scenario to help explain. I can also share the whole pdf via google docs if necessary.
Basically, I need the numbers to automatically calculate into the totals page (8) on my form.
Scenario 1:
If "H" is chosen in "Owner 1.0" (which is the owner column) and the amount is $100.00 in "Market Value 1.0", then $100.00 should automatically be shown in "HusbandTotal1.0.0" under summary of values. If "W" is chosen for "Owner 1.1" and the amount is $100.00 for "Market Value 1.1" then $100.00 should automatically be shown in "WifeTotal1.0" under summary of values. and for the last one, say "W" is chosen for "Owner 1.2" and the amount is $50.00, then that amount would be added to the $100.00 that is already in "WifeTotal1.0" for a total of $150.00 in "WifeTotal1.0".
Scenario 2:
If "H" is chosen for "Owner 1.0" and the amount is $100.00 in "Market Value 1.0", then it should automatically be shown in "HusbandTotal1.0.0" under summary of values. then, if "H" is chosen again for "Owner 1.1" and another $100.00 is in "Market Value 1.1", then that would be added to "HusbandTotal1.0.0" under summary of values. and again, if "H" is chosen for "Owner 1.2" for another value of $100.00 in "Market Value 1.2", then that would be added to "HusbandTotal1.0.0" and the total amount for "HusbandTotal1.0.0" would be $300.00
The calculation I currently have for the "HusbandTotal1.0.0" is:
var amount = Number(this.getField("Market Value 1.0").value) + Number(this.getField("Market Value 1.1").value) + Number(this.getField("Market Value 1.2").value);
var owner = (this.getField("Owner 1.0").valueAsString) + (this.getField("Owner 1.1").valueAsString) + (this.getField("Owner 1.2").valueAsString);
if(owner=="W") event.value = 0;
else if (owner=="W-JTO") event.value = 0;
else if (owner=="H") event.value = amount;
else if (owner=="H-JTO") event.value = amount;
else if (owner=="JTS") event.value = amount/2;
else event.value = "";
The calculation I currently have for the "WifeTotal1.0" is:
var amount = Number(this.getField("Market Value 1.0").value) + Number(this.getField("Market Value 1.1").value) + Number(this.getField("Market Value 1.2").value);
var owner = (this.getField("Owner 1.0").valueAsString) + (this.getField("Owner 1.1").valueAsString) + (this.getField("Owner 1.2").valueAsString);
if(owner=="H") event.value = 0;
else if (owner=="H-JTO") event.value = 0;
else if (owner=="W") event.value = amount;
else if (owner=="W-JTO") event.value = amount;
else if (owner=="JTS") event.value = amount/2;
else event.value = "";
