Automatic Form Submission

Hi !

I’m trying to have a form that automatically submits after a certain amount of time.
My page contains a Wixform and a submit #button1 (They have been dragged and dropped from the wix elements)

So far, I have been able to code a 30 min countdown timer, and I have a “If” trigger when the countdown reaches 0…
I want to have this trigger either submit the form, or automatically press the #button1.

Here is my code:

$w . onReady ( function () {
var countDownDate = new Date (). getTime ()+( 1800000 ); // Countdown 30 min

var x = setInterval ( function () {
var now = new Date (). getTime ();
var distance = countDownDate - now ;
var hours = Math . floor (( distance % ( 1000 * 60 * 60 * 24 )) / ( 1000 * 60 * 60 ));
var minutes = Math . floor (( distance % ( 1000 * 60 * 60 )) / ( 1000 * 60 ));
var seconds = Math . floor (( distance % ( 1000 * 60 )) / 1000 );

    $w ( "#text17" ). text  =  minutes  +  "m "  +  seconds  +  "s " ; 

if ( distance < 0 ) {
clearInterval ( x );
//here, either submit the form or “Click #button1
}
}, 1000 );

});

Thanks in advance!

Run this CODE… (and take a closer look into —> CONSOLE.

Try to understand all steps! Expand the code for your own needs, adding further functions and features to it.

$w.onReady(function () {
    var countDownDate = new Date().getTime() + (5000); 
    var x = setInterval(function () {

        var now = new Date().getTime();
        var distance = countDownDate - now;
        var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
        var seconds = Math.floor((distance % (1000 * 60)) / 1000);

        console.log( minutes + "m " + seconds + "s ");

        if (distance < 0) {clearInterval(x); console.log("COUNTER-STOPPED!!!");
            console.log("START YOUR FUNCTION HERE!!!!");
            myFunction()
        }
        else {console.log("COUNTER still running...");}
    }, 1000);

});

function myFunction(params) {
    console.log("NOW SOMETHING STARTED AUTOMATICALY AFTER THE COUNTER WAS DOWN!!!");
    console.log("GENERATE WHAT EVER YOU WANT HERE!!!"); 
}

READ THIS POST ADDITIONALY…
community.wix.com
[SOLVED] How to query a date field and show with a lamp if it isn´t empty? | Velo by WixI have tried for days now to make this work but still fail so please have a loo