I need help creating a script that will read through several fields, and if any one of them meets a condition (let's say, "Yes"), then Checkbox1 is checked.
The pseudocode would be:
If Field1 is Yes
or If Field2 is Yes
or If Field3 is Yes
or If Field4 is Yes
then Checkbox1 = checked
So, a "Yes" one of those fields generates the check in the box.
The other part of this is if someone were to set Fields 1-4 to "Yes" and then back to "No", I need a script that checks all four fields and if they are all "No", then sets Checkbox1 to unchecked.
I can't code, but I know how to edit/add existing script. I really appreciate any help.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Maybe something like this JavaScript code in the calculate event of the checkbox field
if (Field1.rawValue == "No" && Field2.rawValue == "No" && Field3.rawValue == "No" && Field4.rawValue == "No")
{
this.rawValue = "0";
}
else
{
if (Field1.rawValue == "Yes" || Field2.rawValue == "Yes" || Field3.rawValue == "Yes" || Field4.rawValue == "Yes")
{
this.rawValue = "1";
}
else
{
this.rawValue = "0";
}
}
Views
Replies
Total Likes
Hi,
Maybe something like this JavaScript code in the calculate event of the checkbox field
if (Field1.rawValue == "No" && Field2.rawValue == "No" && Field3.rawValue == "No" && Field4.rawValue == "No")
{
this.rawValue = "0";
}
else
{
if (Field1.rawValue == "Yes" || Field2.rawValue == "Yes" || Field3.rawValue == "Yes" || Field4.rawValue == "Yes")
{
this.rawValue = "1";
}
else
{
this.rawValue = "0";
}
}
Views
Replies
Total Likes
Great, thanks! I have two questions, I hope you don't mind:
1. Why does one if-statement have "&&" and the other has "||"?
2. It seems like both conditions are already taken care of in the first two if/else statements. What is the final "else" statement for?
Views
Replies
Total Likes
I think I figured out the "or" vs. "and" function of && and ||. So the only question remains about the final "else" statement. Thanks.
Views
Replies
Total Likes
Hi,
You may not need the else, I wasn't sure what other values the fields might have than Yes or No.
Regards
Bruce
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies