Copy link to clipboard
Copied
I'm new to scripting in Adobe, but not necessarily new to scripting/coding in general. I think my biggest issue right now is asking the right question and understanding how Adobe runs scripts.
I have a fillable form, and within this form I have 3 checkboxes. ChckBox1, ChckBox2, ChckBox3.
ChckBox2 and ChckBox3 should be read only when the file is opened. If a user checks ChckBox1, ChckBox2 and ChckBox3 should become editable, but not selected by default as they are optional fields.
I could do this pretty easily by adding actions using Prepare Form, but my actual form has more than 3 checkboxes and I want to script it at the document level. What I think is happening is that the document level script runs when the file is opened, because I call it, but then doesn't check the fields for updates as it only runs once. I want it to continuously check the values of certain "parent" boxes to update the read status of "child" boxes.
Below is the script. When the file opens, ChckBox2 and ChckBox3 are in read only state as desired. If ChckBox1 is checked, ChckBox2 and ChckBox3 remain read only.
function CheckBoxTest(){
if (this.getField("ChckBox1").value == "Off") {
this.getField("ChckBox2").readonly = true;
this.getField("ChckBox3").readonly = true;
}
else if (this.getField("ChckBox1").value == "Yes") {
this.getField("ChckBox2").readonly = false;
this.getField("ChckBox3").readonly = false;
}
}
CheckBoxTest();
Copy link to clipboard
Copied
Call function from checkbox1 Mouse UP action.