Skip to main content
Dreamy_77
Known Participant
March 16, 2016
Question

Limit the number of checkboxes that can be selected

  • March 16, 2016
  • 2 replies
  • 3834 views

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!

This topic has been closed for replies.

2 replies

Known Participant
March 24, 2016

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:

 

  1. A special variable (nc) is needed to keep track of the number of checks still allowed.
  2. A special variable (ncLimit) is needed for the total number of simultaneous checks allowed.
  3. The initial state of the system: no checks and nc=ncLimit.
  4. The MouseUp event of every checkbox should have the following update logic:
    1. When a check event occurs
      1. Deduct 1 from nc.
      2. If nc < 1 then set readonly=true for every checkbox that is still unchecked.
    2. When an uncheck event occurs
      1. Add 1 to nc.
      2. If nc<2 then set readonly=false for every checkbox that is still unchecked.

[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.

 

Participant
May 25, 2023

I could not get the pdf to open

 

Nesa Nurani
Community Expert
Community Expert
May 26, 2023

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?

try67
Community Expert
Community Expert
March 16, 2016

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.