Is it possible to trigger a download by clicking a Submit button?

  • Profile Image
    BWG
    Asked on January 23, 2015 at 07:06 PM

    I know that we can link to a file for downloading by choosing it as a custom "thank you" page, but what I would love to be able to do is to take the visitor to a "real" thank you page and initiate a file download at the same time, by clicking a "Submit" button.

    Is there any way of doing that?

    Vlad

  • Profile Image
    Charlie
    Answered on January 23, 2015 at 10:02 PM

    Hi Vlad,

    I believe this is possible if you will be using javascript to your thank you page url.

    Here's a guide on that: https://www.jotform.com/help/89-Create-a-Custom-Thank-you-page-with-Auto-redirect. But this is more of a redirect.

    Here's a quick guide on how to have a thank you page and have a download redirect.

    1. Here's the code for the thank you page url.

    This is the javascript code:

    <script type="text/javascript">

    var timer = 3; //seconds

     website = "https://shots.jotform.com/charlie/Test.pdf"

    function delayer() {

     window.open(website, '_blank');

    }

    setTimeout('delayer()', 1000 * timer); 

    </script>

    2. I then added it on a thank you page url.

     

    Here's the demo form: http://form.jotformpro.com/form/50228522520949

    You can further advance this process but we'll need to further our coding skills. Do you want to directly download the file without our browser blocking it as a pop-up?

    I hope this helps or at least gives you an idea on how to proceed. Let us know if you need more assistance.

    Thank you.