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

restrictions on check boxes

Avatar

Level 4

Hello,

I am working on a form where there are 3 checkboxes to choose from, when you click on the box a hidden form comes up.  I would like to set up the form so that if a one of the check boxes are clicked on, it does not allow the other two forms to open.  The remaining 2 check boxes can be opened at the same time, but the 3rd cannot be open at the same time as the other 2.

I hope this makes sense. If anyone can help i would greatly appreciate it.


Thank you,

Nik

7 Replies

Avatar

Level 7

The easiest way to do it would be to simply not allow the user to click the other 2 checkboxes if the first checkbox is filled.

on checkbox1:

if (this.rawValue == 1){ \\ checkbox is filled

     checkbox2.access = "protected";

     checkbox3.access = "protected";

}

if (this.rawValue == 0){ \\ checkbox is unfilled

     checkbox2.access = "open";

     checkbox3.access = "open";

}

Then you can simply reverse it for the other 2 that are allowed to be open together, the script would be the same for both checkboxes:

if (this.rawValue == 1){ \\ checkbox is filled

     checkbox1.access = "protected";

}

if (this.rawValue == 0){ \\ checkbox is unfilled

     checkbox1.access = "open";

}

If the user can't click the checkboxes, the hidden forms can't be open.

Avatar

Level 4

Thank you for your response. I have followed under the 'click' event. Is this correct, or should it be entered elsewhere? If it is suppose to be in the click event, it did not work for me.

Avatar

Level 7

The click event is the correct event, did you change the paths and field names to match your form? Without access to your form I have no way of knowing the exact names of your checkboxes and their paths within the hierarchy. The script I posted used checkbox1, checkbox2 and checkbox3 for the field names and assumed that all 3 checkboxes are on the same page. You will need to modify the script to fit your form.

Avatar

Level 4

Yes, i have changed it to match my form.  I also have this in the click event:

if

(chkDeleteDependant.rawValue == "1")

{deleteDependant.presence

="visible";

deleteDependant.surname.mandatory

="error";

deleteDependant.firstname.mandatory

="error";

deleteDependant.birthday.mandatory

="error";

deleteDependant.birthmonth.mandatory

="error";

deleteDependant.birthyear.mandatory

="error";}

else

if

(chkDeleteDependant.rawValue = "0"){

deleteDependant.presence

="hidden";

deleteDependant.surname.mandatory

="disabled";

deleteDependant.firstname.mandatory

="disabled";

deleteDependant.birthday.mandatory

="disabled";

deleteDependant.birthmonth.mandatory

="disabled";

deleteDependant.birthyear.mandatory

="disabled";}

is it possible that this has something to do with why it is not working?

Avatar

Level 7

Possibly; this line:

(chkDeleteDependant.rawValue = "0"){

should have a double equal (==) in it for the boolean check. If that's how your script is written anything after that may not execute.

Avatar

Level 4

im still having problems.

Thank you for your help anyway.

Avatar

Level 10

For troubleshooting and for good coding practice, please use TRY CATCH block to make your life easier.

try

{

      // Write your code here

}catch(e)

{

     app.alert("Exception:" +e);

}

now, you might get some details about the exception.

Nith