Trying to use FOR and IF to count specific fields on a page
Hello,
I am trying to get a field on each page to show a total of the number of buttons on that field's page that have a specific caption ( "X," "(X)," or "OUT OF TIME"). My goal is to be able to paste a copy of this field on each page with a unique name and have it work without needing to change the code. So far my field just displays "1" whether the criteria are met or not, and doesn't update when I change the button captions. (The buttons are set to cycle through a set of captions when I click on them.) By default, all buttons' captions are "", but after clicking, the captions will cycle through "X," "(X)," "OUT OF TIME," "OK," and back to "".
I'm not great with "for" loops yet, so I'm not sure what I'm missing.
for (var i = 0; i < this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
var reg = /btnOriginal/;
var count = 0;
if (f.pageNum == event.target.pageNum && f.name.match(reg) && f.buttonGetCaption == "X" || "(X)" || "OUT OF TIME") {
count++
};
};
event.value = count;Any help is greatly appreciated!
