Copy link to clipboard
Copied
Hello, I am working on a form where once one checkbox is clicked, I need it to automatically check another box. My issue is I need the checkbox that would automatically be checked to have the capability to be unchecked without unchecking the first checkbox. Is this do-able?
Well, step one is to give the second field a unique name. Let's say the first one is called CB1 and the second CB2.
Add this code as the Mouse Up event of CB1:
if (event.target.value!="Off") this.getField("CB2").checkThisBox(0, true);
Copy link to clipboard
Copied
Should the second check-box be un-checked when the first one is?
Copy link to clipboard
Copied
Yes. It should only be checked when the first one is. The first checkbox is the general product, and there are 6 checkboxes underneath as options. We want one option to be automatically checked once the first box to checked, but have the capability to choose another checkbox if the customer wants a different option. Currently, if I try to uncheck the second checkbox, it unchecks the first one, which I don't want to do.
Copy link to clipboard
Copied
Well, step one is to give the second field a unique name. Let's say the first one is called CB1 and the second CB2.
Add this code as the Mouse Up event of CB1:
if (event.target.value!="Off") this.getField("CB2").checkThisBox(0, true);
Copy link to clipboard
Copied
Hi try67,
Thank you for your response! I renamed both of the check boxes and for the CB1 I did the following: Clicked properties, actions, select trigger: mouse up, select action: run a JavaScript, and then I copied and pasted the following into the "Add.." field:
if (event.target.value!="Off") this.getField("CB2").checkThisBox(0, true);
Unfortunately, the second box doesn't automatically check now. Did I do something wrong?
(Thank you for your help as I am very new to this and trying to understand )
Copy link to clipboard
Copied
Is the other field named CB2?
Copy link to clipboard
Copied
Oh my gosh, there was a typo! Now that is it "CB2" it works like a charm! Thank you so, so much for your help! It is greatly appreciated!