Closing Form Lightbox after submitting Email and Name via form

Hi

I’m really new to Wix Corvid and a bit lost to figure out how I can solve my Problem.

I was building an PopUp lightbox to advertise our new online cooking class.

The form appears here after 30 seconds:
https://www.ayurvedaroom.ch/kochkurse

The ID of the lightbox is:

onlinekochkurspopup

The ID of the form send button is:

sendbutton

My goal is that when someone filled all the three fields and clicks on the Send Button, the lightbox will close after about three seconds (programmed delay, to show the success message).

What do I have to write in the code section?

I’m lost… I tried severaly solutions in this forum, but the lightbox never closed…

Looking forward to learn from you guys! (=

Juten Tag der Herr!

How to use code for lightboxes?

https://www.wix.com/corvid/reference/wix-window/lightbox-obj/close

Close a lightbox…

wixWindow.lightbox.close();

Do also not forget to import …(das kommt nach ganz oben)

import wixWindow from'wix-window';

Giving a time-delay…

setTimeout(()=>{},3000) //---> 3-sec.

Your Code should then look like this one…

import wixWindow from'wix-window'

$w.onReady(function()=>{
    $w('#YourButtonID').onClick(()=>{console.log("Click")
        setTimeout(()=>{wixWindow.lightbox.close()},3000)
    )}
})

Try to complete this code.

Good luck and happy coding.

Hi Dima

Thanks for your help.

If I copy&paste your code I get the following debugging error:

parsing error: unexpected tokken =>

If I delete that I get the next error at the end of the function.

I was searching for similar functions, but I haven’t found a solution.

Do you see what’s wrong?

Sorry I’m pretty newbie with Wix Corvid. But I wanna learn this!

@stemeier3
So sieht man sich wieder ^^.

Ok, that was my fault, sorry i did not test my own code :grin:

This one should be better.

$w.onReady(function (){
    $w('#button1').onClick(()=>{console.log("Click")
        setTimeout(()=>{wixWindow.lightbox.close()},3000)
    })
}

@russian-dima Thank you so much! It works!

https://www.ayurvedaroom.ch/kochkurse

Is it possible to make a if-function to only make the lightbox close when the costumer filled in all the information into the form?

Else it will close after 3 seconds showing my costumer the “fill form”-error and close the lightbox without sending me the costumer information.

Of course it is possible, you have just to CODE it :grin:

Wenn mein Eingabefeld “ungleich” —>“”, dann mach dies und das…
ansonsten mach was anderes!
(For you, for better understanding your own code later ^^)

Now we are using the code-language and not German xD

if ( ...here the IF-statement...) {...here then-statement...}
else {...here ELSE-statement} 
if ($w('#element1_ID').value !== "" && ($w('#element1_ID').value !== "" && ($w('#element1_ID').value !== "" ){ 

 //here ---> START YOUR PROCESS ---> CONTINUE

}

else {
 //STOP PROCESSING (DO NOTHING or what ever)
}

Something like this…

$w.onReady(function (){
    $w('#button1').onClick(()=>{console.log("Click")
 if ($w('#input1').value !== "" && ($w('#input2').value !== "" && ($w('#input3').value !== "" ){ 

            setTimeout(()=>{wixWindow.lightbox.close()},3000)

        }

 else {
 //STOP PROCESSING (DO NOTHING or what ever)
        } 
    })
}

Dima du bist mein Held! :grinning:

Hatte ein paar kleine Fehler, aber so funktionierts! :smiley:

$w.onReady(function (){
    $w('#sendbutton').onClick(()=>{console.log("Click")
 if ($w('#InputVorname').value !== "" && $w('#InputNachname').value !== "" && $w('#InputEmail').value !== "" ){ 
 //here ---> START YOUR PROCESS ---> CONTINUE
        setTimeout(()=>{wixWindow.lightbox.close()},3000)
        }else {
 //STOP PROCESSING (DO NOTHING or what ever)
        } 
    })
})

Danke vielmals du bist Spitze!

PS:
Ich habe mir deine Webseite angeschaut. Mega toll!
Werde sicher ein paar Tutorials machen.

@stemeier3 Kein Problem!

Do not forgett to translate the main messages (it’s normaly an english spoken forum). :wink:

P.S. Du kannst meinen Posts auch folgen.
And do not forget to like it, if you really liked it :wink: