Opening an external link upon clicking submit button in Wix Form

Hi,

What I want to happen specifically on my site is this:

  1. A user on a product page clicks on the “Spec Sheet” button

  1. A lightbox pops up with a form prompting them to enter their email in order to download the spec sheet

THE PART WHERE I NEED HELP ↓

  1. The user clicks on the “download” button, which submits their email AND opens a new window with the PDF/link.

Note: I realize that this is easy to do with pretty much any other wix button, but it is not a built-in option on form/submit buttons, so I figure the only option is to add it with code.


I’ve already reviewed the solutions provided in these posts here:

But, I wanted to see if there is a better way to do this, especially since I don’t want to necessarily “redirect” from the current page, I just want a link to open in a new page.

Here is the code I have added:

import wixLocation from 'wix-location';

export function button3_click(event, $w) {
    wixLocation.to("https://docs.talen-x.com/ProductSummaries/BroadSense.pdf");
  }

UPDATE: I have considered a different coded solution where I leave the submit button as is, and add a separate “download” button that is hidden upon the page loading, but appears when the submit button is clicked and is placed exactly above the submit button. And since it would be a regular button it has the built in option of opening a new window.

BUT, I still want to hear your feedback first :slight_smile:

Thank you!!
-Rachael

You actually don’t need code for this!

  1. Connect your button to your dataset, link to submit.
  2. When successful, navigate to A link…
    3. Choose web address and paste your link and select new window.

I’ll suggest you use I want to receive marketing communications instead of I do not fort the check box.

Hi! I´m having similar problem. In my case, the destination link is a local dinamic page that must receive same parameter that actual form has. It is not working…

I tried doing the same but rather with a URL Field in a Content Collection rather than a link (To make the link dynamic) and It wont work… After submitting it just doesn’t do anything…

Any answer?

Hi
I don’t seem to have an option to connect a button to dataset. I have a ‘Subscribe’ form within the light box. When the submit button is clicked I’d like an external link(PDF) to be opened in a NEW TAB. Is there a way to do so?