The code is as follows:
// Checkbox element name prefix, this example is Sample1, Sample2, Sample3 ...
Var sctrlprefix = "sample";
// Checkbox elements, this example has 18;
VAR imaxcheckbox = 18;
// Set the maximum number of allowable selection;
Var iMaxSelected = 5;
Function Docheck (Ctrl) {
Var inumchecked = 0;
Var thisctrl;
Var i;
//initialization
i = 1;
// Circular until the most Checkbox is selected;
While ((i <= iMaxcheckbox) && (InumChecked <= iMaxSelected) {
Thisctrl = evAl ("Ctrl.form." SctrlPrefix i);
IF ((thisctrl! = ctrl) && (thisctrl.checked) {
InumChecked ;
}
i ;
}
/ / Check if it reaches the maximum number of choices;
IF (InumChecked == iMaxSelected) {
// If you are the elements that uncheck just selected;
Ctrl.checked = false;
}
}
// ->
Script>