Copy link to clipboard
Copied
Basically I'm looking for a master / slave type of behavior.
I have four checkboxes, cb0, cb1, cb2, and cb3. I'd like to check cb0 if ANY of the others are checked and uncheck cb0 if ALL of the others are unchecked. I would think there is a simple solution here as it should simply read somthing like:
var f0 = getField("cb0");
var f1 = getField("cb1");
var f2 = getField("cb2");
var f3 = getField("cb3");
if (f1.value === "On" || f2.value === "On" || f3.value === "On") {
f1.value = "On";
} else {
f1.value = "Off";
}
Many thanks in advance!
The script probably doesn't work because "On" is not the export value for the checkboxes.
Read about checkboxes here: Checkboxes and Radio buttons
The script is best used in a calculation script. Any calculation script on the form. You could even create a hidden field just for this purpose. The idea is to capture any change in the checkbox values, including programatic changes. The MouseUp script will only work for user interaction. It's also spread out over 3 fields, whereas the calculation script is in one place.
Copy link to clipboard
Copied
Basically I'm looking for a master / slave type of behavior.
I have four checkboxes, cb0, cb1, cb2, and cb3. I'd like to check cb0 if ANY of the others are checked and uncheck cb0 if ALL of the others are unchecked. I would think there is a simple solution here as it should simply read somthing like:
var f0 = getField("cb0");
var f1 = getField("cb1");
var f2 = getField("cb2");
var f3 = getField("cb3");
if (f1.value === "On" || f2.value === "On" || f3.value === "On") {
f1.value = "On";
} else {
f1.value = "Off";
}
Many thanks in advance!
The script probably doesn't work because "On" is not the export value for the checkboxes.
Read about checkboxes here: Checkboxes and Radio buttons
The script is best used in a calculation script. Any calculation script on the form. You could even create a hidden field just for this purpose. The idea is to capture any change in the checkbox values, including programatic changes. The MouseUp script will only work for user interaction. It's also spread out over 3 fields, whereas the calculation script is in one place.
Copy link to clipboard
Copied
Why do you set the value of f1?
Copy link to clipboard
Copied
I meant to set f0 instead. I'm not sure that my syntax is sound here. Thanks again!
Copy link to clipboard
Copied
This search provides a wealth of information on programming checkboxes, including exactly your question.
https://forums.adobe.com/search.jspa?q=checkbox
About your code. You didn't ask any questions about it. Did you write this code? Does it produce an errors? Where is this code placed?
If you'd like help, then these are all important.
1) As Bernd states, it is f0 you want to set, not f1
2) Did you set all the checkbox export values to "On"? Cause the default on value is "Yes".
3) The location of this code is very important. It should be placed in a calculation script, so all the check box clicks are captured.
Copy link to clipboard
Copied
I wrote the code on the fly but it hasn't worked for me. I thought I would put it in a Mouse Up action for all checkboxes other than cb0...? Is syntax an issue? Obviously I meant to set f0 and not f1. Sorry about that and thanks again for your feedback!
Copy link to clipboard
Copied
The script probably doesn't work because "On" is not the export value for the checkboxes.
Read about checkboxes here: Checkboxes and Radio buttons
The script is best used in a calculation script. Any calculation script on the form. You could even create a hidden field just for this purpose. The idea is to capture any change in the checkbox values, including programatic changes. The MouseUp script will only work for user interaction. It's also spread out over 3 fields, whereas the calculation script is in one place.
Copy link to clipboard
Copied
This is perfect! Thanks, Thom!