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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

conditional addition based on checkbox

Avatar

Level 1

I have a field that adds the values from several other form fields.  The question I have is how do I add another 2 if a certain checkbox is both visible and checked?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You would need an if/else statement that looks at the value of the checkbox.

This could be in the calculate event of the field that displays the answer:

var tempAnswer = numericfield1.rawValue + numericfield2.rawValue + numericfield3.rawValue;

if (checkbox.presence == "visible" && checkbox.rawValue == 1)

{

     tempAnswer = tempAnswer + numericfield4.rawValue + numericfield5.rawValue;

}

this.rawValue = tempAnswer;

You would need to change the object references, etc, but it should give you a structure to work with. We have examples here, some of which include objects with calculation scripts: http://assure.ly/eEPuCM

Hope that helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

You would need an if/else statement that looks at the value of the checkbox.

This could be in the calculate event of the field that displays the answer:

var tempAnswer = numericfield1.rawValue + numericfield2.rawValue + numericfield3.rawValue;

if (checkbox.presence == "visible" && checkbox.rawValue == 1)

{

     tempAnswer = tempAnswer + numericfield4.rawValue + numericfield5.rawValue;

}

this.rawValue = tempAnswer;

You would need to change the object references, etc, but it should give you a structure to work with. We have examples here, some of which include objects with calculation scripts: http://assure.ly/eEPuCM

Hope that helps,

Niall

Avatar

Level 1

Thanks.  I thought it was something like that, but couldn't quite get it right.