Copy link to clipboard
Copied
Hi there,
I have multiple checkboxes (named "CheckBox1", "Checkbox2", and "CheckBox3")
I would like it so that the end-user can individually check these checkboxes and they have the option to click a separate checkbox (let's name it "CheckBoxAll") so that all of the checkboxes are checked and the CheckBox1, 2, and 3 are also locked. If the CheckBoxAll is then unchecked, it will revert back to all boxes being unchecked.
I'm guessing I would want a Mouse Up JavaScript in the CheckBoxAll checkbox, but I can't figure out what to put in there.
Any ideas? Thanks in advance.
Glenn
Copy link to clipboard
Copied
Yes, use MouseUp in CheckBoxAll:
if(event.target.isBoxChecked(0)){
this.getField("Checkbox1").checkThisBox(0,true);
this.getField("Checkbox1").readonly = true;
this.getField("Checkbox2").checkThisBox(0,true);
this.getField("Checkbox2").readonly = true;
this.getField("Checkbox3").checkThisBox(0,true);
this.getField("Checkbox3").readonly = true;}
else{
this.getField("Checkbox1").checkThisBox(0,false);
this.getField("Checkbox1").readonly = false;
this.getField("Checkbox2").checkThisBox(0,false);
this.getField("Checkbox2").readonly = false;
this.getField("Checkbox3").checkThisBox(0,false);
this.getField("Checkbox3").readonly = false;}
Copy link to clipboard
Copied
You can set a field to read-only to prevent a user from interacting with it. The code for a single checkbox can be as simple as:
getField("Checkbox1").readonly = true;
and you can set it to false to make it user selectable.
The code can be simplified if you use hierarchcal naming for the group of checkboxes (e.g., group1.cb1, group1.cb2, etc.) and the code to disable all in the group can be:
getField("group1").readonly = true;
Copy link to clipboard
Copied
Yes, use MouseUp in CheckBoxAll:
if(event.target.isBoxChecked(0)){
this.getField("Checkbox1").checkThisBox(0,true);
this.getField("Checkbox1").readonly = true;
this.getField("Checkbox2").checkThisBox(0,true);
this.getField("Checkbox2").readonly = true;
this.getField("Checkbox3").checkThisBox(0,true);
this.getField("Checkbox3").readonly = true;}
else{
this.getField("Checkbox1").checkThisBox(0,false);
this.getField("Checkbox1").readonly = false;
this.getField("Checkbox2").checkThisBox(0,false);
this.getField("Checkbox2").readonly = false;
this.getField("Checkbox3").checkThisBox(0,false);
this.getField("Checkbox3").readonly = false;}
Copy link to clipboard
Copied
Yet again to the rescue! Thank you Nesa.
CheckBoxes 1, 2, and 3 also have their own scripts and I was hoping that when the above CheckBoxAll script ran that the individual scripts in CheckBox1, 2, and 3 would then run too...But they didn't...Probably because I didn't specify they needed to!!!
I tested the following (with the first checkbox) which seemed to work, and I just wondered if by doing this format for the remaining checkboxes is this the best/only way, or is there an easier way for this to work?
if(event.target.isBoxChecked(0)){
this.getField("CheckBoxNA7.1").checkThisBox(0,true);
this.getField("CheckBoxNA7.1").readonly = true; }
if(event.target.value != "Off"){
this.getField("Score7.1").value = "";
this.getField("CheckBoxD7.1").value = "Off";
this.getField("CheckBoxD7.1").readonly = true;}
else
this.getField("CheckBoxNA7.1").checkThisBox(0,false);
this.getField("CheckBoxNA7.1").readonly = false;
if(event.target.value == "Off"){
this.getField("Score7.1").value = 3;
this.getField("CheckBoxD7.1").readonly = false;}
Copy link to clipboard
Copied
It won't run script automatically,if you set up script in MouseUp event then you need to click on field to activate script.
If you want to run that script when "CheckBoxAll" is clicked then add script to "CheckBoxAll" MouseUp event, or make hidden text field and put script in "Custom calculaton script" so it will execute automatically.
Copy link to clipboard
Copied
That makes perfect sense. Thank you.

