/    Sign up×
Community /Pin to ProfileBookmark

countdown /refresh

Hello everyone,

I copied below the code for a countdown which will start after the user has clicked on a button (web page related to a language test), it works but there are two more things wrong and I can’t identify the causes:

1- After having started the countdown by clicking on the start button, if I update the page, the countdown is desactivated, so if the user updates he can repeat the test as he pleases … it should not be possible

2- always after clicking on the start button, all the fields indicate that they must be filled in (validated) while this function is triggered, normally, only when the user submits the test and a field is missing that he did not check.

Thank you,

`$(document).ready(function (){

jQuery(function($){
$(‘#startClock’).on(‘click’, doCount);
});

function checkform()
{
if (!document.form1.q7[0].checked &&
!document.form1.q7[1].checked) {
alert(‘Toutes les réponses doivent être renseignées’);
return false;
}
};
function afficherchamp() {
document.getElementById(“q13″).style.display=”block”;
document.getElementById(“q14″).style.display=”block”;
document.getElementById(“q15″).style.display=”block”;
document.getElementById(“q17″).style.display=”block”;
document.getElementById(“q19″).style.display=”block”;
document.getElementById(“q21″).style.display=”block”;
document.getElementById(“q25″).style.display=”block”;
document.getElementById(“q27″).style.display=”block”;
document.getElementById(“q29″).style.display=”block”;
document.getElementById(“q31″).style.display=”block”;
document.getElementById(“q33″).style.display=”block”;
document.getElementById(“q35″).style.display=”block”;
document.getElementById(“q37″).style.display=”block”;
document.getElementById(“q39″).style.display=”block”;
document.getElementById(“q41″).style.display=”block”;
document.getElementById(“q43″).style.display=”block”;
document.getElementById(“q45″).style.display=”block”;
document.getElementById(“q47″).style.display=”block”;
document.getElementById(“q50″).style.display=”block”;
document.getElementById(“q59″).style.display=”block”;
document.getElementById(“q61″).style.display=”block”;
document.getElementById(“q63″).style.display=”block”;
document.getElementById(“q65″).style.display=”block”;
document.getElementById(“q67″).style.display=”block”;
document.getElementById(“q69″).style.display=”block”;
document.getElementById(“q71″).style.display=”block”;
document.getElementById(“q73″).style.display=”block”;
document.getElementById(“q75″).style.display=”block”;
document.getElementById(“q77″).style.display=”block”;
document.getElementById(“q79″).style.display=”block”;
document.getElementById(“q81″).style.display=”block”;
document.getElementById(“q83″).style.display=”block”;
document.getElementById(“q85″).style.display=”block”;
document.getElementById(“q88″).style.display=”block”;
}

function doCount(){
var xMinutes = 15;
var xSeconds = 59;
document.getElementById(“count”).innerHTML = “Top: ” + xMinutes + “:” + xSeconds;
var timer = setInterval(function() {
$(“#YourButton”).prop(‘disabled’,true);
xSeconds–;

if (xSeconds < 10) {
document.getElementById(“count”).innerHTML = “Il vous reste: ” + xMinutes + “:0” + xSeconds;
}
else {
document.getElementById(“count”).innerHTML = “Il vous reste: ” + xMinutes + “:” + xSeconds;
}
if (xMinutes == 0 && xSeconds == 0) {
$(“#YourButton”).prop(‘disabled’,true);
clearInterval(timer);
alert(“Temps écoulé! Votre test sera soumis automatiquement”);
}
if (xSeconds == 0) {
xMinutes–;
xSeconds = 59;
}
}
, 1000)

var auto_refresh = setInterval(function() {
submitform();}, 2100000);
// Form submit function
function submitform() {
{
alert(‘Soumission automatique du formulaire…’);
document.getElementById(“form1”).submit();
}
}

};“`

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @grace007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...