Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Custom Calculation Formula Needed

paulh77730136
Level 1
Level 1

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?

1 Accepted Solution
MinusZero
Correct answer by
Level 7
Level 7

Hi, You could try this.

I created a button to calculate the totals. My test uses only 5 textfields.

1658197_pastedImage_0.png

In the calculate button i had:

form1.#subform[0].Button1::click - (JavaScript, client)
var totP = 0; //set variable for the Ps
var totT = 0; //set variable for the Ts

if(TextField1.rawValue == "P")
{
totP = totP + 1;
}
if(TextField2.rawValue == "P")
{
totP = totP + 1;
}
if(TextField3.rawValue == "P")
{
totP = totP + 1;
}
if(TextField4.rawValue == "P")
{
totP = totP + 1;
}
if(TextField5.rawValue == "P")
{
totP = totP + 1;
}

if(TextField1.rawValue == "T")
{
totT = totT + 1;
}
if(TextField2.rawValue == "T")
{
totT = totT + 1;
}
if(TextField3.rawValue == "T")
{
totT = totT + 1;
}
if(TextField4.rawValue == "T")
{
totT = totT + 1;
}
if(TextField5.rawValue == "T")
{
totT = totT + 1;
}

totalP.rawValue = totP; //display the total Ps
totalT.rawValue = totT; //display the total Ts

This is one way to do it. Some considerations are that javascript is very particular. T is not the same as t. You would need to account for that. eg: if(TextField1.rawValue == "T" || TextField1.rawValue == "t")

1658198_pastedImage_1.png

View solution in original post

1 Reply
MinusZero
Correct answer by
Level 7
Level 7

Hi, You could try this.

I created a button to calculate the totals. My test uses only 5 textfields.

1658197_pastedImage_0.png

In the calculate button i had:

form1.#subform[0].Button1::click - (JavaScript, client)
var totP = 0; //set variable for the Ps
var totT = 0; //set variable for the Ts

if(TextField1.rawValue == "P")
{
totP = totP + 1;
}
if(TextField2.rawValue == "P")
{
totP = totP + 1;
}
if(TextField3.rawValue == "P")
{
totP = totP + 1;
}
if(TextField4.rawValue == "P")
{
totP = totP + 1;
}
if(TextField5.rawValue == "P")
{
totP = totP + 1;
}

if(TextField1.rawValue == "T")
{
totT = totT + 1;
}
if(TextField2.rawValue == "T")
{
totT = totT + 1;
}
if(TextField3.rawValue == "T")
{
totT = totT + 1;
}
if(TextField4.rawValue == "T")
{
totT = totT + 1;
}
if(TextField5.rawValue == "T")
{
totT = totT + 1;
}

totalP.rawValue = totP; //display the total Ps
totalT.rawValue = totT; //display the total Ts

This is one way to do it. Some considerations are that javascript is very particular. T is not the same as t. You would need to account for that. eg: if(TextField1.rawValue == "T" || TextField1.rawValue == "t")

1658198_pastedImage_1.png

View solution in original post