Copy link to clipboard
Copied
Hi there - I'm working on a questionnaire form - and need to limit the user to be able to select a maximum of three checkboxes (from a total of 16) on one of the questions.
Any help on how to do this would be much appreciated!
Copy link to clipboard
Copied
This requires a complex script which needs to be attached to the Mouse Up event of each check-box. The script should iterate over all of the boxes in the list, counting how many of them are ticked. If the maximum number has been reached it should change the value of the box that triggered it to be un-ticked, and possibly show an error message.
Copy link to clipboard
Copied
Consider a Petri Net model for limiting the number of checks in a set of checkboxes (Chionglo, 2016); the following solution or control logic is based on the Petri Net model:
[A PDF version of this reply includes two sample forms that obey the checkbox limit using the control logic described above: http://www.aespen.ca/AEnswers/zngeW1458711009.pdf ].
References
Chionglo, J. F. (2016). “A reply to ‘limit the number of checkboxes that can be selected’” at Adobe, PDF Forms Discussions. Available at http://www.aespen.ca/AEnswers/zlEsm1458624106.pdf.
Copy link to clipboard
Copied
I could not get the pdf to open
Copy link to clipboard
Copied
There is no need for script in each checkbox, it can be done by using calculation script in a text field.
Can you explain what you try to achieve exactly?
Copy link to clipboard
Copied
The web site is not more available.
Copy link to clipboard
Copied
var ncLimit = 3;
var nc = ncLimit;
function freezeUncheckedCheckboxes(dc) {
var fld, j;
for (j=1; j<6; j++) {
fld = dc.getField("CheckBox" + j);
if (fld.value=="Off") {
fld.readonly = true;
}
}
}
function unfreezeCheckboxes(dc) {
var fld, j;
for (j=1; j<6; j++) {
fld = dc.getField("CheckBox" + j);
if (fld.readonly) {
fld.readonly = false;
}
}
}
switch(event.target.value) {
// check event
case "Yes":
nc -= 1;
if (nc<1) { freezeUncheckedCheckboxes(this); }
break;
// uncheck event
case "Off":
nc += 1;
unfreezeCheckboxes(this);
break;
default:
console.show();
console.println("Error checkbox (" + event.target.name
+ ") value. Unrecognized value ... '" + event.target.value + "'. Must be 'Yes' or 'Off'.");
break;
}