Can't get radio buttons or checkboxes to update live via validation in another field?
I'm working on customizing a test that uses a lot of totals that funnel into a final percentage. The totals are sums of dropdowns that add between 0 and 1 point to the score (plus there is a text field for deductions at the end). Eventually there is a final total and a percentage. The percentage uses both the Calculate tab and the Validate tab.
The calculation works great and is this:
var a = this.getField("Numerator").value;
var b = this.getField("Denominator").value;
if (b != "" && b != 0) {
event.value = a/b;
}
else {
event.value = "";
}
The validation works for our general use cases, and turns on/off two radio buttons for Pass or Fail:
var percentage = event.value;
if (percentage >= 0.90) {
this.getField("pass").value ="Choice1";
this.getField("fail").value ="None";
} else if (percentage < 0.90) {
this.getField("fail").value ="Choice1";
this.getField("pass").value ="None";
}
However, I'm trying to add automatic fail functionality that works off a set of radio buttons (so even if the score is over 90%, having one of these radio buttons selected will fail the test). I previously tried doing this with checkboxes as well. If I put the code directly into the radio or checkboxes, I can mostly get the live update to work. Ideally I'd like to have it all in one spot though, in the validation field mentioned above.
To do this, I tried the following:
var percentage = event.value;
var errors = [this.getField("Option01"),
this.getField("Option02"),
this.getField("Option03"),
this.getField("Option04"),
this.getField("Option05"),
this.getField("Option06")];
var autoFail = false;
for (var i = 0; i < errors.length; i++) {
if (errors[i].value == "NC" || errors[i].value == "MT") {
autoFail = true;
}
}
if (autoFail) {
this.getField("overfail").value ="Choice1";
this.getField("overpass").value ="None";
} else {
if (percentage >= 0.90) {
this.getField("pass").value ="Choice1";
this.getField("fail").value ="None";
} else if (percentage < 0.90) {
this.getField("fail").value ="Choice1";
this.getField("pass").value ="None";
}
}
..Which sort of works, but nothing actually happens after you change the radio button. The change doesn't reflect in the Pass/Fail radio buttons until I update a dropdown or field as well, which changes the final total. I'm wondering if this is because those are all connected throughout the calculations, whereas the radio buttons only show up in the process at the very end in that one validate tab? I'm a bit of a javascript notice and sometimes unsure of how acrobat decides things in calculations. Any advice would be helpful!

