Skip to main content
annak87309989
Known Participant
June 7, 2018
Question

automatically check that the name of checkbox not repeated

  • June 7, 2018
  • 1 reply
  • 614 views

I have an interactive forms document. contains almost 200 elements: checkboxes and text field. it takes a lot of time to check the check boxes - if the names are not repeated (then when selecting one, two are marked). Is it possible to write an automatic test or script that will check if the names are not repeated? and how to write such a test? in what? where are I writing?

This topic has been closed for replies.

1 reply

BarlaeDC
Community Expert
Community Expert
February 28, 2020

HI,

 

[I know this is old, but I was sure there was a solution, in case it can help]

 

The script works by checking all the checkboxes using checkThisBox method which allows us to only check single boxes and uncheck any that have multiple entries.

 

var numFields = this.numField; // get all fields in the document

for ( var i = 0; i < numFields; i++) {
    var curField = this.getField(this.getNthFieldName(i)); // get each field in turn
    if (curField.type == "checkbox"){ // if it is a checkbox
        for ( var j = 0; j < 2; j++){
            curField.checkThisBox ( j, j == 0); // if first instance check it, else uncheck it.
        }
    }
}

 

This means that after this script is run any checkbox that is unchecked has a duplicate field.

 

Regards

 

Malcolm