Skip to main content
paulh77730136
Participant
December 28, 2018
Answered

Custom Calculation Formula Needed

I have 31 text boxes, one for each day of the month.  In each text box there are 5 or 6 different entries, such as P, T, AB, AT.  I want to create a field to total the P's and T's but not the AB's and AT's.  How do I do that?

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
December 29, 2018

OK, then you can use this code as the custom calculation script of the total field:

var total = 0;

for (var i=1; i<=31; i++) {

    var v = this.getField("Smith "+ i).valueAsString;

    if (v=="P" || v=="T") total++;

}

event.value = total;

Edit: Forgot to add a space after "Smith"...

4 replies

try67
Community Expert
Community Expert
December 28, 2018

What are the names of those fields?

Translate
paulh77730136
Participant
December 28, 2018

Smith 1 through Smith 31

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 29, 2018

OK, then you can use this code as the custom calculation script of the total field:

var total = 0;

for (var i=1; i<=31; i++) {

    var v = this.getField("Smith "+ i).valueAsString;

    if (v=="P" || v=="T") total++;

}

event.value = total;

Edit: Forgot to add a space after "Smith"...

Translate