Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q917 How can I count down from 15 seconds and then display an alert message?

irt.org | Knowledge Base | JavaScript | Date | Q917 [ previous next ]

Q917 How can I count down from 15 seconds and then display an alert message?

Try:

<form name="timer">
<input type="text" value="" name="field">
</form>

<script language="JavaScript"><!--
var counter = 15;

function countDown() {
    document.timer.field.value = counter-- + ' seconds left';
    if (counter != -1)
        setTimeout('countDown()',1000);
    else
        alert('You lose');
}

countDown();
//--></script>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.