/ Id-Extras Forum / FormMaker 4.0 (Show/hide)

  • Author
  • #8080 Reply
    anaspk212
    Participant

      Hello,

      I am working on a simple show/hide in PDF using FormMaker 4.0 on an iMac.
      I was able to make it work with the code below to show/hide info, but on inital opening the boxes are checked and the result is showing. Is there a way where I can have it uncheked and the info would be hide?

      Layer 4 is what I am trying to hide/show when the box is checked. I am also using native Adobe Indesign to map out the boxes.

      This is the code I am using:

      var ocgArray = this.getOCGs();
      for (var i = 0; i < ocgArray.length; i++) {
      if (ocgArray[i].name === “Layer 4”) {
      ocgArray[i].state = (event.target.value === “Yes”);
      }
      }

       

       

      Thank you in advance,

      Anas

      #8091 Reply
      Ariel
      Keymaster

        Hi Anas,

        Essentially, it should all work nicely.

        There is a subtle syntax error in your code. In this line if (ocgArray[i].name === “Layer 4”) { the quotes around Layer 4 are curly. They should be plain quotes: if (ocgArray[i].name === "Layer 4") {. I think you’ve got the same problem with “Yes”: It should be "Yes" with straight quotes.
        The working script should look like this:

        var ocgArray = this.getOCGs();
        for (var i = 0; i < ocgArray.length; i++) {
        if (ocgArray[i].name == "Layer 4") {
        ocgArray[i].state = (event.target.value === "Yes");
        }
        }
        

        To have Layer 4 hidden initially, make sure it is hidden in InDesign when you export the interactive PDF, and make sure to uncheck the Checkbox option “Check box is checked by default”:

        Make sure to download the latest version of FormMaker as well, which is currently 4.0.8 (click on the About button in FormMaker to see the full version).

        Post back if you still need help to get it to work.

        Here’s a link to an InDesign 2023 file and a PDF showing how it works:

        http://www.id-extras.com/wp-content/uploads/2024/05/ShowHideLayerExample.zip

         

      Viewing 2 posts - 1 through 2 (of 2 total)

      Tagged: 

      Reply To: FormMaker 4.0 (Show/hide)
      Your information: