Skip to main content
Participating Frequently
October 15, 2019
Answered

PDF/JavaScript/Checkbox

  • October 15, 2019
  • 2 replies
  • 3191 views

Hello,

 

I have a simple PDF that has several checkboxes on it. What I'm wanting to do is have a specific PDF open depending on what checkboxes get checked (users clicks on a "Submit" button when done selecting forms). So, let's say the checkbox for form 026 is checked (026Cb), and so is the checkbox for form 053 (053Cb), but nothing else, then open an already saved PDF packet that has just those two forms in it. I added code that just dislays a message for now and get it to work for one checkbox check, but keep getting errors when trying to add more checkboxes to it. This will basically be a big nested if/else type check. Here is what I have.

if (this.getField("026Cb").value != "Off")
{app.alert("026 Checked", 3);}
else {app.alert("026 not Checked", 3);}

    This topic has been closed for replies.
    Correct answer try67

    You have multiple errors in your code.

    1. The OR operator in JS is "||".

    2. There's no such command as fopen in Acrobat JS.

    3. Your file-path syntax is incorrect.

     

    Try this:

    app.openDoc("/S/shz_online_agreements/site_files/packets/066p_PAF.pdf");

    2 replies

    try67
    Community Expert
    try67Community ExpertCorrect answer
    Community Expert
    October 15, 2019

    You have multiple errors in your code.

    1. The OR operator in JS is "||".

    2. There's no such command as fopen in Acrobat JS.

    3. Your file-path syntax is incorrect.

     

    Try this:

    app.openDoc("/S/shz_online_agreements/site_files/packets/066p_PAF.pdf");

    Participating Frequently
    October 16, 2019
    That worked. Thanks for your help.
    try67
    Community Expert
    Community Expert
    October 15, 2019

    What errors are you getting? What code are you using?

    Participating Frequently
    October 15, 2019
    Hello, I now made it a bit farther. I can perform the check if all the checkboxes are checked. But having trouble writing the needed command, that if all the checkboxes are checked, then open a specific PDF file on my Shared drive. This is what I now have. Using the javascript editor in Adobe Acrobat Standard DC. if (this.getField("026Cb").value != "Off" | this.getField("053Cb").value != "Off" | this.getField("065Cb").value != "Off" | this.getField("068Cb").value != "Off" | this.getField("069Cb").value != "Off" | this.getField("071Cb").value != "Off" | this.getField("072Cb").value != "Off") {file = fopen("S:\shz_online_agreements\site_files\packets\066p_PAF.pdf", 3);}