Copy link to clipboard
Copied
Hi
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 become unchecked/cleared (if they were previously checked), but at the same time checkbox 2 and checkbox3 also become disabled/read-only (by disabled I mean not checkable, not clickable, just read-only).
I have a javascript that does kind of the opposite (which I earlier got help with on this forum on a similar but different case).
It looks like this: checkbox1 checked then checkbox2 and checkbox 3 become checked and disabled/read-only.
And the script for this looks like this:
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");
So as a rookie I have tried to experiment with this script as a base but no solution so far.
Appreciate your help on this
/Dennis
Copy link to clipboard
Copied
It is important to work through the logic.
When you say that checking 1 causes 2 to become unchecked if it was checked, but doesn't do anything if 2 is already unchecked. The result is that checking 1 always unchecks 2. This is an important simplification when you go to write the code.
So here is a variation that only changes 2 & 3 (to unchecked) when 1 is checked, but leaves them untouched when 1 is unchecked
Notice that the export values for 2 & 3 are not used, since they are only being turned off (unchecked). The code never checks 2 & 3.
var bChecked = (event.target.value == "Yes")
this.getField("checkbox3").readonly = bChecked;
this.getField("checkbox2").readonly = bChecked;
if(bChecked)
{
this.getField("checkbox3").value = "Off";
this.getField("checkbox2").value = "Off";
}
Copy link to clipboard
Copied
Thanks, I got it 🙂
Find more inspiration, events, and resources on the new Adobe Community
Explore Now