Copy link to clipboard
Copied
Hello all,
I have 3 check marks, when I check one I want the others to be read only or hidden, I also have 11 fields that need to be read only or hidden depending on which check mark is selected. Knowledge of coding is less than basic 😩. I appreciate anyones help, thank you!
Copy link to clipboard
Copied
Let's say your checkboxes are named "check1","check2","check3".
I would use hidden text field with custom calculation script:
var c1 = this.getField("check1");
var c2 = this.getField("check2");
var c3 = this.getField("check3");
//Set "check1" to readonly if "check2" or "check3" are checked
c1.readonly = c2.valueAsString != "Off" || c3.valueAsString != "Off" ? true : false;
//Set "check2" to readonly if "check1" or "check3" are checked
c2.readonly = c1.valueAsString != "Off" || c3.valueAsString != "Off" ? true : false;
//Set "check3" to readonly if "check1" or "check2" are checked
c3.readonly = c1.valueAsString != "Off" || c2.valueAsString != "Off" ? true : false;
To include text fields, you need to tell us field names and what are conditions when should they be hidden/read-only.
Copy link to clipboard
Copied
Thank you so much for your reply and assistance. In order for this to work do I add action show/hide? Meaning for checkbox 1 add show/hide for checkbox 2 and 3 then add the Java script? The fields I need to show hide are if checkbox 1 is selected hide Field 4-field 11, checkbox 2 hide field 1-4 & 8-11, and checkbox 3 hide field 1-8. Or would it make more sense to instead of hiding the field make them visible based on which checkbox is selected, i.e if checkbox 1 is selected make fields 1-4 visible, checkbox 2 selected make fields 5-8 visible, and when checkbox 3 is selected make fields 9-11 visible? Thank you for all your help on this!
Copy link to clipboard
Copied
Add this to the previous script I gave you:
this.getField("field1").display = c1.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field2").display = c1.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field3").display = c1.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field4").display = c1.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field5").display = c2.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field6").display = c2.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field7").display = c2.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field8").display = c2.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field9").display = c3.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field10").display = c3.valueAsString == "Off" ? display.hidden : display.visible;
this.getField("field11").display = c3.valueAsString == "Off" ? display.hidden : display.visible;
Copy link to clipboard
Copied
Thank you! So I added a hidden text field and added a custom calculation script where I pasted both scripts you provided (thank you so much), but when I preview form it doesn't run the script. Is there something I am missing? Thank you for all you help!
Copy link to clipboard
Copied
Share your file.
Copy link to clipboard
Copied
++ Adding to the discussion,
See if this recent discussion helps:
There is a good link to an article that explains how checkboxes and radio button widgets work .
In addition , note the example script; which you can modify to meet your requirement.