2 Replies Latest reply on Nov 29, 2015 6:19 AM by tracyy42935226

    Question with how to show layer on a document level automatically- javascrip at document level?


      I have a form in which the user immediately selects their favorite color in a Dropdown list called FavColor- they choose between three colors:  Blue, Yellow or Green.  Based on the user selection, customized layers (either BlueLayer or YellowLayer or GreenLayer) are immediately shown with additional specific questions for the user.  Right now I have the below Javascript in the validate area of the FavColor dropbox.  It works great.  My problem comes after the user saves the document and I try to reopen it to print it.  The data is all there but the relevant layer doesn't automatically show up (I must reenter their FavColor to get it to run the script again).  CAn someone help me come up with a solution for this? Is there a way to run a script when a document is opened to determine which layer should show?  Or should I have the user save the file differently so that input is 'committed' to the document?  I'm still rather new at javascript and programming these forms so thank you in advance for your help!


      var layers = this.getOCGs(0);

      for (var i in layers) {

          if (layers[i].name=="BlueLayer")

              layers[i].state = (event.value=="Blue");

          else if (layers[i].name=="YellowLayer")

              layers[i].state = (event.value=="Yellow");

          else if (layers[i].name=="GreenLayer")

              layers[i].state = (event.value=="Green");