Copy link to clipboard
Copied
So working on this form and the intention is to keep sub-sections read only unless the main section is checked off. It works but if I hit the clear button after enabling those sub-section fields change to non-read-only (not sure what you would call that).
main section checkbox is using this JS script:
if (this.getField("IL-CHECK").value=="Off") {
this.getField("IL-BK").readonly = true;
this.getField("IL-CL").readonly = true;
this.getField("IL").readonly = true;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = true;
this.getField("IL-CL-OVG").readonly = true;
this.resetForm(["IL-BK", "IL-CL", "IL", "IL-OTHER", "IL-BK-OVG", "IL-CL-OVG"]);
} else {
this.getField("IL-BK").readonly = false;
this.getField("IL-CL").readonly = false;
this.getField("IL").readonly = false;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = false;
this.getField("IL-CL-OVG").readonly = false;
}
and sub-section checkboxes are using this:
if (this.getField("IL").value == "3")
{
this.getField("IL-OTHER").readonly = false;
}
else
{
this.resetForm(["IL-OTHER"]);
this.getField("IL-OTHER").readonly = true;
}
Copy link to clipboard
Copied
The form reset only affects field values, it doesn't reset the read-only property. What you need to do is add a script to the "Clear" button. Buttons can run more than one action so you can have both the Reset and the "Run a JavaScript" together. Copy the code for restting the readOnly values into this script.
You might also consider using Group Naming to make these form handling operations easier.
For example "IL.Other" "IL.BK-OVG" , Now you can reset the values and the readOnly like this
this.getField("IL").readonly = true;
this.resetForm("IL");
Copy link to clipboard
Copied
The form reset only affects field values, it doesn't reset the read-only property. What you need to do is add a script to the "Clear" button. Buttons can run more than one action so you can have both the Reset and the "Run a JavaScript" together. Copy the code for restting the readOnly values into this script.
You might also consider using Group Naming to make these form handling operations easier.
For example "IL.Other" "IL.BK-OVG" , Now you can reset the values and the readOnly like this
this.getField("IL").readonly = true;
this.resetForm("IL");
Copy link to clipboard
Copied
Thom, TY for the easy explanation. Im not experienced at all with scripting and really just following the patterns to figure out what goes where. Your suggestion worked as expected. Thanks!
Copy link to clipboard
Copied
Thom, totally seperate but from the code above you can see I am using a checkbox to enable and diable text fields.
I have 3 sections doing the same behavior. I was looking at an example you posted about using checkboxes as radio buttons (because you can uncheck a checkbox) but im having difficulty figuring out make it work.
So if you look at the text doc pdf i posted orginally these 3 sections enable the fields (INCLUDED IN LEASE, BILLED SEPERATELY, WIDE FORMAT). How would I maintain the same function using your approach to checkboxes being used as radio buttons.
Thanks again.
Copy link to clipboard
Copied
Just give all the check boxes the same field name and different "Export" values, then they are part of the same mutual exclusivity group. The Export value is on the "Options" tab in the Properties dialog
Copy link to clipboard
Copied
I gave all the checkboxes the same field name "MA" and export values as "1,2,3" but i then it seems to have broken my above code for enabling/disabling.
this was in the first checkbox.
if (this.getField("MA").value=="Off") {
this.getField("IL-BK").readonly = true;
this.getField("IL-CL").readonly = true;
this.getField("IL").readonly = true;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = true;
this.getField("IL-CL-OVG").readonly = true;
this.resetForm(["IL-BK", "IL-CL", "IL", "IL-OTHER", "IL-BK-OVG", "IL-CL-OVG"]);
} else {
this.getField("IL-BK").readonly = false;
this.getField("IL-CL").readonly = false;
this.getField("IL").readonly = false;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = false;
this.getField("IL-CL-OVG").readonly = false;
}
Then for the first sub section I did:
if (this.getField("IL").value == "1")
{
this.getField("IL-OTHER").readonly = false;
}
else
{
this.resetForm(["IL-OTHER"]);
this.getField("IL-OTHER").readonly = true;
}
And then I added this to the CLEAR BUTTON:
if (this.getField("MA").value=="Off") {
this.getField("IL-BK").readonly = true;
this.getField("IL-CL").readonly = true;
this.getField("IL").readonly = true;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = true;
this.getField("IL-CL-OVG").readonly = true;
this.resetForm(["IL-BK", "IL-CL", "IL", "IL-OTHER", "IL-BK-OVG", "IL-CL-OVG"]);
} else {
this.getField("IL-BK").readonly = false;
this.getField("IL-CL").readonly = false;
this.getField("IL").readonly = false;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = false;
this.getField("IL-CL-OVG").readonly = false;
}
if (this.getField("MA").value=="Off") {
this.getField("BS-BK").readonly = true;
this.getField("BS-CL").readonly = true;
this.getField("BS-CPC").readonly = true;
this.getField("BS-BK-MIN").readonly = true;
this.getField("BS-CL-MIN").readonly = true;
this.getField("BS-OTHER").readonly = true;
this.resetForm(["BS-BK", "BS-CL", "BS-CPC", "BS-BK-MIN", "BS-CL-MIN", "BS-OTHER"]);
} else {
this.getField("BS-BK").readonly = false;
this.getField("BS-CL").readonly = false;
this.getField("BS-CPC").readonly = false;
this.getField("BS-BK-MIN").readonly = false;
this.getField("BS-CL-MIN").readonly = false;
this.getField("BS-OTHER").readonly = true;
}
if (this.getField("MA").value=="Off") {
this.getField("WF-BK").readonly = true;
this.getField("WF-CL").readonly = true;
this.getField("WF-CPC").readonly = true;
this.getField("WF-BK-MIN").readonly = true;
this.getField("WF-CL-MIN").readonly = true;
this.getField("WF-OTHER").readonly = true;
this.resetForm(["WF-BK", "WF-CL", "WF-CPC", "WF-BK-MIN", "WF-CL-MIN", "WF-OTHER"]);
} else {
this.getField("WF-BK").readonly = false;
this.getField("WF-CL").readonly = false;
this.getField("WF-CPC").readonly = false;
this.getField("WF-BK-MIN").readonly = false;
this.getField("WF-CL-MIN").readonly = false;
this.getField("WF-OTHER").readonly = true;
}
if (this.getField("PT-OTHER-CB").value=="Off") {
this.getField("PT-OTHER").readonly = true;
this.resetForm(["PT-OTHER"]);
} else {
this.getField("PT-OTHER").readonly = false;
}
What is happening is the checkboxes are acting like radio buttons for the fields in the sub section is not disabling when the checkbox is unchecks and the CLEAR BUTTON now is not resetting all these fields.
Copy link to clipboard
Copied
The current code tests for an "Off" state. This is the prefered method for checkboxes because it works regardless of export value.
However, for radio buttons you need to test for the actual export value, and reverse the order of the code blocks.
For example:
if (this.getField("MA").value=="1") {
this.getField("IL-BK").readonly = false;
this.getField("IL-CL").readonly = false;
this.getField("IL").readonly = false;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = false;
this.getField("IL-CL-OVG").readonly = false;
} else {
this.getField("IL-BK").readonly = true;
this.getField("IL-CL").readonly = true;
this.getField("IL").readonly = true;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = true;
this.getField("IL-CL-OVG").readonly = true;
this.resetForm(["IL-BK", "IL-CL", "IL", "IL-OTHER", "IL-BK-OVG", "IL-CL-OVG"]);
}
Copy link to clipboard
Copied
So the only issue I see is when going from checkbox MA1 to MA2 all of MA1's content is still enabled. The only way to disable MA1's content is to uncheck MA1 directly and deselect using MA2 while MA1 is selected.
also would MA2's first line of code be?
if (this.getField("MA").value=="2") {
Copy link to clipboard
Copied
here is the test doc im working on. you will see that the only was to disable a section is to uncheck the section...simply clicking on another section does not seem to disable the previously enabled section.
https://drive.google.com/file/d/1XklGyfYVBWT0UKCSRV9f8Pat1jSPWEEF/view?usp=sharing
Copy link to clipboard
Copied
Well actually, since you are now using Radio Buttons, all the code for disabling needs to go into every button script.
Radio buttons only turn "ON". They never turn off. So the script on the MouseUp needs to enable the fields in it's section and disable the fields in the other sections.
Copy the diable code from the other buttons into code on the MouseUp.
Another way to do this is to create a document level function that does the duty for all buttons. The call this function in the MouseUp on each button.
Copy link to clipboard
Copied
its seems like I had to include all the "ifs" for all 3 checkboxes in one script...and use that script in all 3 check boxes. Im sure there is a more efficient way but this seems to work.
if (this.getField("MA").value=="1") {
this.getField("IL-BK").readonly = false;
this.getField("IL-CL").readonly = false;
this.getField("IL").readonly = false;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = false;
this.getField("IL-CL-OVG").readonly = false;
} else {
this.getField("IL-BK").readonly = true;
this.getField("IL-CL").readonly = true;
this.getField("IL").readonly = true;
this.getField("IL-OTHER").readonly = true;
this.getField("IL-BK-OVG").readonly = true;
this.getField("IL-CL-OVG").readonly = true;
this.resetForm(["IL-BK", "IL-CL", "IL", "IL-OTHER", "IL-BK-OVG", "IL-CL-OVG"]);
}
if (this.getField("MA").value=="2") {
this.getField("BS-BK").readonly = false;
this.getField("BS-CL").readonly = false;
this.getField("BS-CPC").readonly = false;
this.getField("BS-BK-MIN").readonly = false;
this.getField("BS-CL-MIN").readonly = false;
this.getField("BS-OTHER").readonly = true;
} else {
this.getField("BS-BK").readonly = true;
this.getField("BS-CL").readonly = true;
this.getField("BS-CPC").readonly = true;
this.getField("BS-BK-MIN").readonly = true;
this.getField("BS-CL-MIN").readonly = true;
this.getField("BS-OTHER").readonly = true;
this.resetForm(["BS-BK", "BS-CL", "BS-CPC", "BS-BK-MIN", "BS-CL-MIN", "BS-OTHER"]);
}
if (this.getField("MA").value=="3") {
this.getField("WF-BK").readonly = false;
this.getField("WF-CL").readonly = false;
this.getField("WF-CPC").readonly = false;
this.getField("WF-BK-MIN").readonly = false;
this.getField("WF-CL-MIN").readonly = false;
this.getField("WF-OTHER").readonly = true;
} else {
this.getField("WF-BK").readonly = true;
this.getField("WF-CL").readonly = true;
this.getField("WF-CPC").readonly = true;
this.getField("WF-BK-MIN").readonly = true;
this.getField("WF-CL-MIN").readonly = true;
this.getField("WF-OTHER").readonly = true;
this.resetForm(["WF-BK", "WF-CL", "WF-CPC", "WF-BK-MIN", "WF-CL-MIN", "WF-OTHER"]);
}
Copy link to clipboard
Copied
This works quite well!! You actually couldn't get much more efficient.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more