0

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

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by TySkby
0

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/ ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.