Here’s how I got it done without any Javascript, JQuery or Ajax:
The way to implement is to use the ;URL=newurl.com">
tag. The is a parameter to be included in that tag.
The tag can be placed anywhere in the code file - Not necessarily at the top, not necessarily at the bottom, just anywhere you wish to place it.
The beauty of this tag is that it does NOT stop the execution of the code at itself. It will still execute ALL the code (including that below it) till the remains a non-zero value.
And it will itself get executed ONLY when the value lapses.
Hence, the way to get it going is to use a PHP parameter for $remainingtime
in seconds, and have it updated to the remaining survey time each time a question of the survey is answered by the user.
.';URL=submitbeforetimeend.php" />
Essentially, if the survey is to be completed in 20 minutes max, then start with 1200 as $remainingtime for Q1.
If user takes 50 seconds to answer Q1, update remaining time in the same/next form page for Q2 to 1950, and so on.
If the user finishes only Q15 by the time that $remainingtime
reaches zero, then the meta tag statement will get executed, and it will get redirected to URL=submitbeforetimeend.php
.
This page will have the function to record the users’ answers upto Q15, which serves the purpose without use of any client-side script.
No Javascript, JQuery or Ajax. All user input remains hidden & secure in PHP or whatever variables.