Copy link to clipboard
Copied
Hi,
I've read an earlier explanation of a similiar question, but in my beginner-eyes the discussion became to advance for me to understand.
Therefore, I try to ask my question here instead.
In my pdf form I have three checkboxes named: checkbox1, checkbox2 and checkbox3.
I wish the following to happen:
If checkbox1 is checked, then checkbox2 and checkbox3 also becomes checked,
but at the same time checkbox 2 and checkbox3 also become disabled (by disabled
I mean not checkable, not clickable).
Thank you for helping me out.
/Dennis
Copy link to clipboard
Copied
Thanks alot Thom, now its working perfectly fine. Due to your latest answer you finally helped me realize that the actual problem was that I really thought I had set the export value to “Yes” but in reality the export value was set to “Ja” which is Swedish for “Yes”.
The reason for this is that my Adobe Acrobat Pro DC program has the language setting Swedish (I’m Swedish). When I create I new checkbox in a empty form, the export value is automatically set to “Ja” (Swedish for “Yes”) by default. When I changed the export value from “Ja” to “Yes”, which I should have realized before from your earlier answers, the Script works perfectly fine.
As I’m a Javascript-rookie I didn’t reflect on this until your latest answer.
Again, thanks a lot Thom for explaining this in a very clear and beginner-friendly way, and I’m glad that it finally works.
Copy link to clipboard
Copied
Hi Dennis,
Sorry for the delay in response.
I assume when you were creating this form, you might have copied the fields rather pasting a new field on the form. So when you are acting on a field rest of the fields are copying this action automatically.
Either you can delete all the fields which are copying action from previous fields or rename all the fields with a unique name.
If you already have found a workaround or a solution to this issue, please update this discussion with your findings that will help others.
-Tariq Dar
Copy link to clipboard
Copied
This script also unchecks the check boxes when the first is unchecked
Put this script on the MouseUp script for "checkbox1".
this.getField("checkbox2").value = event.target.value;
this.getField("checkbox2").readonly = (event.target.value == "Yes");
this.getField("checkbox3").value = event.target.value;
this.getField("checkbox3").readonly = (event.target.value == "Yes");
Copy link to clipboard
Copied
Hi Thom,
Thanks for the script you've been given.
I pasted the script on the MouseUp script for "checkbox1" and the following is happening:
This is great, but at the same time the the following is not working:
What am I doing wrong?
/Dennis
Copy link to clipboard
Copied
The ReadOnlyness is not being set properly. There are a couple of things you can do to find out why it's not working.
First, check the box on Checkbox1 and then put the form in "prepare form" mode and open the properties dialog for checkbox2. Check the Export value on the Options tab. Is it set to Yes? If not, change the code to match this export value.
If this is not the issue, then look in the Console Window to see if there are any reported errors.
The Acrobat JavaScript Console Window - YouTube
Also try manually setting the ReadOnly property to see how the check boxes behave.
Copy link to clipboard
Copied
Hi Thom,
Export value
The export value is set to “yes” for all three checkboxes. Still checkbox2 and checkbox3 become just checked when checkbox1 is checked, but they don't become disabled (by disabled I mean not checkable, not clickable).
Set Read Only manually
I’ve also, In addition to the script, manually set Read Only in the properties dialog (on the General tab) for checkbox2 and checkbox3,
What happens then when I go to the preview mode:
-Before I check checkbox1, the other two checkboxes (checkbox2 and checkbox3) are disabled.
-But then when I check checkbox1, the other two becomes checked, but the problem remains that you can still uncheck/check checkbox2 and checkbox3.
After this I go back to the edit mode to the properties dialog (on the General tab) for checkbox2 and checkbox3. Now the Read Only property has deactivated itself. I’ve tested to lock the Read Only after I’ve marked it in the same properties dialog, but I get the same result in preview mode. Afterwards I return to the edit mode to the properties dialog where the “Locked” function is still set, but strange enough the Read Only property has deactivated itself anyway.
Console window
I’ve tested the script in the console window and got this message:
TypeError: event.target is undefined
1:Console:Exec
undefined
As I’m a java script beginner I’ve no clue what this means.
What should I do?
Thanks a lot for helping me out.
Copy link to clipboard
Copied
So your saying that checking "checkbox1" turns the Read Only off for 2 & 3. This make sense if the export value is set to "yes" as you say, since, the code uses "Yes". See the difference? Case matters. The match has to be verbatim. Either change the export value to "Yes' or change the code to use "yes".
Copy link to clipboard
Copied
I didn't mean for you to run the script "as is" in the console. Just to test getting the checkbox1 value setting the read only. The "event" object is only valid in the scripting context of object it's run on. So a field event property doesn't make sense in the console. You have to replace it with the intended value, which is this case is the field object for checkbox1.
Copy link to clipboard
Copied
Thanks alot Thom, now its working perfectly fine. Due to your latest answer you finally helped me realize that the actual problem was that I really thought I had set the export value to “Yes” but in reality the export value was set to “Ja” which is Swedish for “Yes”.
The reason for this is that my Adobe Acrobat Pro DC program has the language setting Swedish (I’m Swedish). When I create I new checkbox in a empty form, the export value is automatically set to “Ja” (Swedish for “Yes”) by default. When I changed the export value from “Ja” to “Yes”, which I should have realized before from your earlier answers, the Script works perfectly fine.
As I’m a Javascript-rookie I didn’t reflect on this until your latest answer.
Again, thanks a lot Thom for explaining this in a very clear and beginner-friendly way, and I’m glad that it finally works.
Copy link to clipboard
Copied
You can do this with a simple script on checkbox1 using JavaScript for PDF forms (like in Adobe Acrobat):
Just place this in the Alano DT Game Download "Mouse Up" action of checkbox1. Hope this simplifies it!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now