Skip to main content
Participant
March 29, 2017
Question

Limit the amount of checkboxes selected on Adobe Acrobat using Javascript?

  • March 29, 2017
  • 1 reply
  • 1608 views

Hi, I am trying to limit the amount of checkboxes that someone can someone can select on a form i created using Adobe Acrobat Pro DC. Below is the javascript that I am using, however I repeatedly keep getting this error message Syntax Error: missing formal parameter 1: at line 2. Can anyone assist?

Thanks

function limitCheckNumber("check", 0, 26, 3) {

   // Initialize the selected check box count

    var count = ;

    // Loop through the check boxes to see if the limit has been exceeded

    for (var i = lower; i < upper + 1; i += 1) {

        // Increment the counter if the current check box is selected

        if (getField(prefix + "." + i).value !== "Off") count += 1;

        // If the count exceeds the limit, deselect the check box that was just selected

        // and alert the user

        if (count > max) {

            event.target.value = "Off";

            app.alert("A maximum of " + max + " check boxes can be selected", 3);

            break;

        }

    }

}

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
March 29, 2017

The error message gives you a clue as to what's wrong... Look at line #2 of your code. You don't see anything strange there?

aphakeyAuthor
Participant
March 29, 2017

Hi, Sorry I am not a programmer so I don't know. Ive tried removing the empty line, doesn't work. Ive tried moving the { to the next line and it doesn't work.

try67
Community Expert
Community Expert
March 29, 2017

The second line of your code (comments and empty lines don't count) is this:

var count = ;

It's like saying "Define a variable called 'count' which is equal to". This makes sense to you?