Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Display a timer

I am in need of some script that displays a timer somwhere on my survey page.

I have to display a 3 minute timer on one survey page and a 45 second timer on another survey page.

If the respondent submits their answers before the timer expires, that's fine. Proceed onwards ...

If the timer expires in either case, I don't need to do anything except say something like "Your time has expired and has been recorded."

Can the timer be displayed in the format #m:##s?

asked Aug 11, 2017 by Paul Moon Platinum (100,795 points)

2 Answers

+1 vote
Place this HTML where you want the timer to appear:

<span class="timerCountdown">3:00</span>
<span class="timerExpired">Expired</span>

CSS can hide the expired message by default:

.timerExpired {
    display: none;

And finally the JS:

    var timer = 3 * 60;
    var interval = setInterval(function(){
        var minute = parseInt(timer / 60);
        var second = timer % 60;
        second = ('0' + second).slice(-2);
        $('.timerCountdown').text(minute + ':' + second);
        if (timer == 0) {
            $('.timerCountdown, .timerExpired').toggle();
    }, 1000);
answered Aug 11, 2017 by Zachary Platinum Sawtooth Software, Inc. (212,550 points)
Thanks Saurabh and Zachary.

Zachary, I have it working for the 3min and 45sec versions. Much appreciated.

Saurabh, feel free to send your code through when you get a chance.
0 votes
I have made a timer in past like this:


If something like this serves the purpose, I can send you code
answered Aug 11, 2017 by Saurabh Aggarwal Gold (34,895 points)
Thanks Saurabh.

I like the actual timer. I don't need any auto submit functionality, just the timer counting down to zero.

Does it come in a #m:##s format?

And when it expires, can it be replaced with a message like "Your time has expired and has been recorded."?
Hi Saurabh,

I have just checked your demo https://demo.sawtoothsoftware.com/adtest/cgi-bin/ciwweb.pl?hid_studyname=adtest&hid_pagenum=0

can you please send me the code for it. I have worked on all the things but unable to get the time for test ad, can you say me how to do for it.

Much appreciated :)