Remove timer from page after time is up | XM Community
Skip to main content
I have inserted the following code which works perfectly and auto-advances to the correct page when the timer is up. The problem is it says "Time Remaining: 00:00" on every page after the time is up. The timer should not show up on the next block once it auto-advances. Can anyone help with this? Qualtrics.SurveyEngine.addOnload(function() { var headerCont = document.createElement("div"); headerCont.className = "header-cont"; headerCont.id = "header_container"; var header = document.createElement("div"); header.className = "header" header.id = "header_1"; var timer = document.createElement("div"); timer.className = "timer"; timer.id = "timer_1"; timer.innerHTML = "Time Remaining: <span id='time'>01:00</span>"; headerCont.appendChild(header); header.appendChild(timer); document.body.insertBefore(headerCont, document.body.firstChild); function startTimer(duration, display) { var timer = duration, minutes, seconds; var myTimer = setInterval(function() { minutes = parseInt(timer / 60, 10) seconds = parseInt(timer % 60, 10); minutes = minutes < 10 ? "0" + minutes : minutes; seconds = seconds < 10 ? "0" + seconds : seconds; var text = ('innerText' in display)? 'innerText' : 'textContent'; display[text] = minutes + ":" + seconds; if (--timer < 0) { clearInterval(myTimer); timeOver(); } }, 1000); } var timerSeconds = 60, display = document.querySelector('#time'); startTimer(timerSeconds, display); var timeOver = function() { Qualtrics.SurveyEngine.setEmbeddedData("blockTimeFlag", "1"); $('NextButton').click(); ;} });
Be the first to reply!