Skip to main content
larryp63548729
Participant
January 23, 2018
Question

ckeck box statement in a form

  • January 23, 2018
  • 3 replies
  • 505 views

Hey!

I have a field named "counter" and a list of 30 check box in my form.

In my script, when the field counter is to 20, I would like to inhibit all the others check box.

Thanks

This topic has been closed for replies.

3 replies

larryp63548729
Participant
January 30, 2018

Hello Tom

Thank you very much for your answer. I will test this new way to solve my problem and i will go back for a feedback

Sincerly

Larry

larryp63548729
Participant
January 25, 2018

Hello Tom,

Thank you for responding so quickly to my question.

I tried the code proposed but it does not work well. Indeed once the threshold is reached, we can not check or uncheck the boxes ....

I will try to be more specific ....

I have a form with a list of 20 checkboxes.

I must choose maximum 10 items.

Once the 10 items reached It can no longer check the remaining boxes.

But, if I uncheck a box I must be able to check any other box until to 20 boxes

Larry P.

Thom Parker
Community Expert
Community Expert
January 25, 2018

This is much more complicated, because what you need is a validation script that only allows checks to turn off after the limit has been reached, and there is no way to enter one for a checkbox from the Acrobat UI.  I think Karl has a solution for entering hidden scripts, KHKonsulting LLC - KHKonsulting LLC

Do this. Use the calculation script to set a document level variable

this.bGo = (event.value < 20); // this is the switch for turning off check entry

The use this validation script in all the check boxes.

event.rc = (event.value == "Off") || this.bGo;

Set the validation script by running this code from the console window

this.getField("Checkbox").setAction('Validate','event.rc = (event.value == "Off") || this.bGo;');

Tricky stuff

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
January 23, 2018

Put this in the Validation script for the form field.

if(event.value >= 20)

{

      this.getField("Check1").readonly  = true;

     this.getField("Check2").readonly  = true;

     this.getField("Check3").readonly  = true;

  ....

}

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often