Tallying button captions (faked tri-state checkboxes) in separate text field
I have a form for teachers to mark attendance for students at either live or online classes. There are 16 possible classes for students to take and they have the option to take any given class either live or online, so I adapted a script from Javascipt for Tri State Button Please Help to let teachers mark attendance for each class as either "live" (checkmark), "online" (star), or "not attending" (blank).
Here is the adapted button script I am running (I use "J" in AdobePi font to make a star symbol):
if (event.target.buttonGetCaption()=="\u2714") {
event.target.buttonSetCaption("J");
} else if (event.target.buttonGetCaption()=="J") {
event.target.buttonSetCaption("");
} else if (event.target.buttonGetCaption()=="") {
event.target.buttonSetCaption("\u2714");
}
Right now I have the attendance buttons for the first student named "a1", "a2", etc. The second student would probably be "b1", "b2", etc.
What I would like is to have is a column for Total Number of Lessons for each student which adds a lesson to a student's total in a text field any time one of that student's attendance buttons is marked with either the checkmark("\u2714") or the star("J"). It should not add a lesson if an attendance button has nothing in it("").
Previously when I had checkboxes on this form I used this script to calculate the total for a participant's entire row of lessons ("a1","a2",etc.):
var sum = 0;
for ( i = 1; i < 17; i++ ) {
f = "a" + i;
field = getField(f);
if (field.isBoxChecked(0)) {
sum = sum + 1;
}
}
event.value = sum;
How can I modify this script so that it calculates the total based on button captions (from multiple buttons across a row) instead?
