Can I link a form submit button to a lightbox

Hi Wix Community,

Very non-tech savvy, so would love any help! I am hoping to link the submit but from a form to a lightbox (so when someone hit’s submit, the lightbox pops up).

How would I do that? Here is what I’ve been trying:

import wixWindow from ‘wix-window’; $w(“#button1”).onClick( (event, $w) => { wixWindow.openLightbox(“lightbox1”); } );

Where #button1 is the ID for the button on the form and “lightbox1” is the name of my lightbox.

What am I missing?!?!

Thanks in advance!

If you are submitting this user input into a dataset, then you can just simply set the dataset submit button to redirect after submission to a new page.
https://www.wix.com/code/home/tutorials-custom-form
https://support.wix.com/en/article/working-with-dataset-actions-for-buttons-and-images
https://www.youtube.com/watch?v=EbwJWRlBsNw (submit button info after the seven minute mark)

Or do it through code with something like this:
https://www.wix.com/code/reference/$w.ClickableMixin.html#onClick

import wixData from 'wix-data';
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';

$w.onReady(function () {
 $w("#button1").onClick( (event) => {
 wixWindow.openLightbox("lightbox1");
 });
 });
 
 //With the onClick function being added to the code itself, you don't need to add the onClick event in the properties panel for that element. However, if you were doing it out of code with an export function, then you would need to apply the onClick function in the element's properties panel.