So the scenario is on my page I have a form along with a countdown timer. If the countdown timer reaches 0:00 I have a statement which activates and is supposed to submit the form as it stands.

here is that statement:

if (Todays_Date >= Target_Date) {
        clearTimeout(timeoutID);
        $('#testForm').submit();
        alert("Timeup, Submitting exam....");
        return;
    }

what actually happens is, it fires, the timer stops (cleared timeout) and alert pops up. However the form does not submit and take the user to the action page.

I have copied all of the code into thisjsfiddle to layout the basic principle.

the time of which countdown is targetted to is passed in the HTML at the bottom. you'll see the countdown() call.

I really am in a pickle and would appreciate someones help.

note: I know this is not a secure method etc.

many thanks

I think it may be your data flow (not sure because I haven't tested it), but I believe this will work:

if (Todays_Date >= Target_Date) {
        clearTimeout(timeoutID);
        alert("Timeup, Submitting exam....");
        $('#testForm').submit();
        return;
    }

or, if that doesn't work, try this:

if (Todays_Date >= Target_Date) {
        clearTimeout(timeoutID);
        var timeup = alert("Timeup, Submitting exam....");
        if (timeup) {
                $('#testForm').submit();
        }
        return;
    }

I'm not sure what the 'return;' is for either, if it's not being set to anything.

Have you read this: http://api.jquery.com/submit/ ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.