mercredi 8 septembre 2021

How do I edit text fields based on checkmarks with JavaScript in Adobe Acrobat?

I am trying to change the text fields in a PDF document in Adobe Acrobat based on which checkmarks are checked. This is what my form looks like below:

enter image description here

I have added the following script to both checkboxes, to be executed on "Mouse Up":

var checkbox1 = event.target.isBoxChecked(0);
var checkbox2 = event.target.isBoxChecked(1);

if (checkbox1 && checkbox2){
    this.getField("Text1").value = "1 and 2";
} else if (checkbox1) {
    this.getField("Text1").value = "Just 1";
} else if (checkbox2) {
    this.getField("Text1").value = "Just 2";
}

I was thinking that this script would record which checkboxes are checked when either of them are clicked and then adjust the text box accordingly, but nothing happens. I do not get any syntax errors when I save the script, either. Any help would be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire