4 Replies Latest reply on Sep 6, 2018 12:53 AM by borisk77927161

    Using form value for dynamic link




      my PDF contains an text input field and a button.


      The value which is entered into the field should be included into a weblink which should be opened in a browser on clicking the button. (e.g. http://www.xxx.yy/theID )


      1) My input field has an ID, and I can get this ID running the following Javascript:


      $id = this.getField('ID').value;


      So I added a first action "Run a Javascript" to this Button, containing this code.


      2) Next step would be to add a second action "Open a web link" to the button, setting the URL e.g. http://www.xxx.yy


      The question is: how can I combine these two actions and put the value of $id into the link of my "open a web link" method to dynamically change the URL to http://www.xxx.yy/theID ?


      For example: I entered 12345 into the field, then on pressing the button http://www.xxx.yy/12345 should be opend!


      Any ideas?


      Thanks a lot

        • 1. Re: Using form value for dynamic link
          try67 MVP & Adobe Community Professional

          First of all , don't put a dollar sign before your variable's name. It's not necessary in JS.

          As for your question: I don't think it can be done using the "Open a web link" action, but it can be done using the "Execute JavaScript" action.

          In it you can use the launchURL method, to which you can specify a URL string. In this string you can include the value of your text field, like so:


          app.launchURL("http://www.xxx.yy/" + this.getField("ID").value);

          • 2. Re: Using form value for dynamic link
            borisk77927161 Level 1

            Hi there,


            recapturing this old forum question. The launchURL-method works nice using the setAction-Method. The problem is, that on mobile devices, the link is not followed when the setAction-Method is used. However if you use "Open a web link" in the action-panel for the button, the web-link is followed also on mobile devices.


            I am currently working on setting field-actions using VBA for MS Excel to set up a pdf-form and ran into that problem. Using VBA I can use the setAction-method for  fields. But the resulting pdf is mainly used on mobile devices. By using the launchURL the links are not followed.


            My question is: What is different between these two methods? Is it possible to program the "Open a web link" in VBA?



            • 3. Re: Using form value for dynamic link
              try67 MVP & Adobe Community Professional

              JavaScript can only set a link's action to execute a JS code. Since VBA uses JS, I don't think you can do it any differently there.

              One possible solution is to use a separate tool to convert those actions from executing a JS code to opening a web-page directly.

              I've developed such a (paid-for) tool, actually, and it can be found here: Custom-made Adobe Scripts: Convert JavaScript Links To Real Links

              1 person found this helpful
              • 4. Re: Using form value for dynamic link
                borisk77927161 Level 1

                Thanks for the information. I'll have a look into your tool.