Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

conditional addition based on checkbox

Avatar

Former Community Member

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

Former Community Member

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