Copy link to clipboard
Copied
Help! I have to count (A) how many times it occurs in the months (therefore in all the days of the year)
I add a code:
var total = 0;
for (var i=1; i<=12; i++) {
for (var j=1; j<=31; j++) {
var f = this.getField("Day"+i+"_"+j);
if (f.valueAsString =="A") total++;
}
}
event.value = total;
Change this:
for (var i=1; i<=12; i++)
To:
for (var i=1; i<=6; i++)
Change this:
if (f.valueAsString =="A") total++;
To:
if (f.valueAsString =="A") {
total++;
f.textColor = color.red;
} else f.textColor = color.black;
Copy link to clipboard
Copied
Since there aren't 31 days in each month, you should probably include code that skips missing fields (unless you have created those fields and they are always empty). Beside that, the code seems fine. What happens when you use it?
Copy link to clipboard
Copied
the months ending on the 30th are left blank.. the problem is that
for (var i=1; i<=12; i++)
doesn't count for me, by checking month by month it reaches July and then it no longer counts as never? Thank you
Copy link to clipboard
Copied
Check the JS Console for error messages.
Copy link to clipboard
Copied
If I want, the counting of A ends on June 30th, what can I do?
Copy link to clipboard
Copied
Change this:
for (var i=1; i<=12; i++)
To:
for (var i=1; i<=6; i++)
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
If I want to color text A in red, what can I do?
Copy link to clipboard
Copied
Change this:
if (f.valueAsString =="A") total++;
To:
if (f.valueAsString =="A") {
total++;
f.textColor = color.red;
} else f.textColor = color.black;
Copy link to clipboard
Copied
Thank you