I'm drafting a form to have an excel style table do some simple budgeting calculations but in adobe. I'm about to tear out my hair because I can't figure out why it isn't functioning properly. I'm a completely self-taught designer so it could be something very basic that I'm missing.
I have a subform that mimics a table so that it can expand by columns instead of rows.
Each subform/column has a drop down (shown in red) that is meant to control a set of checkboxes (in red). There is a switch statement associated with the dropdown on the exit event.
switch(this.rawValue){
case "1": //MTDC
Boxes.checkbox1.rawValue = 1;
Boxes.checkbox2.rawValue = 0;
Boxes.checkbox3.rawValue = 0;
Boxes.checkbox4.rawValue = 1;
...
xfa.form.recalculate(0);
break;
case "2": //TDC
Boxes.checkbox1.rawValue = 0;
...
xfa.form.recalculate(0);
break;
}
Each row of the subform is a different type of expense (supplies, wages, etc.) and includes a checkbox. The checkboxes control a calculation on the change event that determines whether or not the amount for that expense type is included in a subtotal (shown in red).
if (this.rawValue == "1") {
EntryCell.OtherExpX.rawValue = CheckTotal.OtherExp.rawValue; //if checked include in subtotal
}
else{
EntryCell.OtherExpX.rawValue = null; //if unchecked excluded from subtotal
}
xfa.form.recalculate(1);
A secondary column that is hidden "EntryCell.[fieldnameX]" collects the values for rows that are checked and adds them up.
The Problem:
The first time I use the drop down, the checkboxes and subtotal calculations work. If I change the dropdown, the checkboxes change based on the Switch Statement in the dropdown. Their Change Event script doesn't update. So the types of expenses included in the subtotal calculation doesn't get updated. Manually changing the checkboxes at any time still works, just not the by using the drop down more than once.
Example of the error:
If everything worked the calculated fields at the bottom should read:
55,000
55,000
28,600
83,600
Please take pity on this poor autodidact.