Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Checkboxes ignoring readonly property

New Here ,
Dec 07, 2021 Dec 07, 2021

I'm programmatically setting the readonly property on fields of type checkbox to true, but that doesn't seem to have any effect. Checkboxes stay checkable. The only thing that works is to uncheck them.

I have not found any evidence in the docs that checkboxes not being "readonly"-able should be the desired behavior for checkboxes, is it?

TOPICS
JavaScript , PDF forms
776
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 07, 2021 Dec 07, 2021

Where does you set the property? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 07, 2021 Dec 07, 2021

Similar to my question in my other post , I'm setting the propery in Document Javascript. E.g. using the following function:

 

function controlFieldIsSet(field) {
  return field.value == "Choix2" || field.value == "Choix3";
}

function readonlyapep() {
  var controlfield1 = this.getField('option39');
  var controlfield2 = this.getField('option40');

  for (var i = 0; i < this.numFields; i++) {
    var field = this.getField(this.getNthFieldName(i));
    if (field.name.indexOf("apep_") > -1) {
        if (controlFieldIsSet(controlfield1) || controlFieldIsSet(controlfield2)) {
          field.readonly = false;
        } else {
          field.readonly = true;
       }
    }
  }
}
readonlyapep();

 

 I also tried setting readonly to false from the Action of another form field, with the same effect.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 07, 2021 Dec 07, 2021

At document level it will execute the script at document open. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 07, 2021 Dec 07, 2021
LATEST

Are any errors reported in the Console Window?

Are you sure that the readOnly property is being set?

Have you tested it from the console?

 

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines