Search code examples
checkboxadobeacrobat

Perform Action Based on Checking Box in Adobe using Javascript


I'm attempting to change a textbox value whenever a user checks a checkbox in Adobe Acrobat Pro XI using Javascript, and am inexperienced in it. I am getting an error of Syntax Error: Illegal Character 7: at line 9 based on the below code:

//Checked
if (this.getField("myCheckBox").value != "Off") { 
this.getField("myTextBox").value = util.printd("mm/dd/yyyy HH:MM:ss", new  Date());

//Not Checked
} else { 
this.getField("myTextBox ").value = “”;
}

I have the feeling I need to change the brackets somehow, can anyone clarify?

Thanks for any help!


Solution

  • the quotation marks in the else clause are not the "correct" quotation marks

      this.getField("myTextBox ").value = “”;  // <-- change these to ""
    

    also, probably need to remove the white-space after "myTextBox "

    try...

      this.getField("myTextBox").value = "";